Java Reference
In-Depth Information
static int[] numberList() {
// ...
}
The compiler will verify that all static final fields are initialized by the end
of any static initializer blocks, and that non-static final fields are initial-
ized by the end of all construction paths for an object. A compile-time
error will occur if the compiler cannot determine that this happens.
Blank final local variables are useful when the value to be assigned to
the variable is conditional on the value of other variables. As with all
local variables, the compiler will ensure that a final local variable is ini-
tialized before it is used.
Local variables and parameters are usually declared final only when
they will be accessed by a local, or anonymous inner, classthough some
people advocate always making parameters final, both as a matter of
style, and to avoid accidentally assigning a value to a parameter, when a
field or other variable was intended. Issues regarding when you should,
and should not, use final on fields were discussed on page 46 .
 
Search WWH ::




Custom Search