Thursday, October 23, 2008

Variable Declarations (Objective 1.3)

Instance variables can
  1. Have any access control
  2. Be marked final or transient
Instance variables can't be abstract, synchronized, native, or strictfp.
It is legal to declare a local variable with the same name as an instance variable; this is called "shadowing."
  1. final variables have the following properties:
  2. final variables cannot be reinitialized once assigned a value.
  3. final reference variables cannot refer to a different object once the object has been assigned to the final variable.
  4. final reference variables must be initialized before the constructor completes.
There is no such thing as a final object. An object reference marked final does not mean the object itself is immutable.
The transient modifier applies only to instance variables.
The volatile modifier applies only to instance variables.

No comments: