What are free floater code? [on hold]

99
July 16, 2017, at 9:05 PM

which code can be considered free floaters ? I am java beginner and I want to know how can I figure out free floater code.

public class Ocz2{
//Ocz2 obj = new Ocz2();
int a[] ;
a=new int[3];
}

In the above code, I am not able to figure out why it is throwing error on line 3. same declaration(line 3 & 4) doesn't throw any error inside method. But from error and google search I got to know it is because free floater code. Kindly help.

Answer 1

Yes your line

a=new int[3];

Is free floater as it doesn't belong to a block, constructor or a function. Java doesn't allow free floating code.

Wrap your line in any block, constructor or in a function.

Answer 2

Problem with your class do not have any function. Therefore , the correct way would be using main function.

public class Ocz2{
public static void main(String args[]){
//Ocz2 obj = new Ocz2();
int a[] ;
 a=new int[3];
  }
 } 
READ ALSO
Not able to set custom color in XSSFCell Apache POI

Not able to set custom color in XSSFCell Apache POI

I am trying to set some custom(from hexcode or rgb value) color to a xssfcellBut the color of the cell is becoming black even though I am giving some other color

63
Runtime error	time: 0.06 memory: 4386816 signal:-1

Runtime error time: 0.06 memory: 4386816 signal:-1

I got Runtime error time: 006 memory: 4386816 signal:-1 for the following code on ideone

73
Message broker data storage format?

Message broker data storage format?

When java producer sends the data any message broker(MB) queue/topic like Apache Kafka/active MQ, it serializes the data and sends the dataDoes MB deserializes the data and then storing it or just stores the object as it is(in serialized form)?

76
Influxdb Versioning / Audit Data

Influxdb Versioning / Audit Data

Suppose simple measurement 'price':

75