Variable Declarations



  • Instance variables can Have any access control
  • 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."
  • final variables have the following properties:
  • final variables cannot be reinitialized once assigned a value.
  • final reference variables cannot refer to a different object once the object has been assigned to the final variable.
  • 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.