Originally posted by Dan Culache:
My question is:
Aren't option c (A final field that is not assigned a value at compile time is called a blank final variable) and option f (At the end of the instance construction process all blank final variables must be definitely assigned) incompatible?
If I don't assign a value to a final variable (in an initializer block, in the constructor or on the same line) I never pass the compiler phase, right?
That means a blank final variable cannot exist at runtime, once a blank final variable is assigned it is no longer blank.
Am I missing something?
If not then having final blank variables at compile time is just a fancy way of saying that the compilation failed?
comp.lang.javascript FAQ: http://jibbering.com/faq/
If I don't assign a value to a final variable (in an initializer block, in the constructor or on the same line) I never pass the compiler phase, right?
That means a blank final variable cannot exist at runtime, once a blank final variable is assigned it is no longer blank.
Aren't option c (A final field that is not assigned a value at compile time is called a blank final variable) and option f (At the end of the instance construction process all blank final variables must be definitely assigned) incompatible?
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Originally posted by Dan Culache:
can I have a running program that has a blank final variable. Again I'm asking about scenarios where this might be possible.
SCJP 1.4
8.3.1.2 final Fields
It is a compile-time error if a blank final (�4.5.4) class variable is not defi-
nitely assigned (�16.7) by a static initializer (�8.7) of the class in which it is
declared.
A blank final instance variable must be definitely assigned (�16.8) at the end
of every constructor (�8.8) of the class in which it is declared; otherwise a compile-
time error occurs.
But it must be remembered that, for
the purposes of the Java programming language, the concept of definite unassignment
is applied only to blank final variables. If V is a blank final local variable,
then only the method to which its declaration belongs can perform assignments to
V. If V is a blank final field, then only a constructor or an initializer for the class
containing the declaration for V can perform assignments to V; no method can perform
assignments to V.
SCJP 1.4
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |