Size is 990
Size is -10
Size is 990
Size is 990
Thanks & regards,
Sunil
When all else fails, follow instructions. - Allen's Axiom
public static final SizeClass INSTANCE = new SizeClass(10);
private static final int MAX_SIZE = getMaxSize();
private static final int MAX_SIZE = getMaxSize();
public static final SizeClass INSTANCE = new SizeClass(10);
public static final SizeClass INSTANCE = new SizeClass(10);
private static final int MAX_SIZE = 1000;
Thanks & regards,
Sunil
When all else fails, follow instructions. - Allen's Axiom
Originally posted by Rohit Dhodapkar:
Hi Saurabh,
By the above statement do you mean in case when a finite value is assigned to a static final vaiable then the top to bottom rule of initialization is not applicable. Because if it is applicable there would be still forward referencing in the constructor.. Please explain
8. Next, execute either the class variable initializers and static initializers of the class, or the field initializers of the interface, in textual order, as though they were a single block, except that final class variables and fields of interfaces whose values are compile-time constants are initialized first (�8.3.2.1, �9.3.1, �13.4.8).
Originally posted by Rohit Dhodapkar:
Hi Henery,
That clarifies my doubt . final variable are compile time constants.
I noted if we remove the final from
private final int size;
The result is - 10 .
Thanks for that.
The expression can't use any other variable that is not a compile time constant.
Size is -10
Size is 990
Thanks & regards,
Sunil
When all else fails, follow instructions. - Allen's Axiom
Get out of my mind! Look! A tiny ad!
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|