18 January 2012 By Nithya Vasudevan 314 views No Comment
0 Flares 0 Flares ×
- A final variable – value cannot be changed once initialized and attempt to change the value will result in a compiler error.
- Provides us security and thread safety
- If your object is accessed by multiple threads, and you don’t declare its fields final, then you must provide thread-safety by some other means.
final int SIZE = 10; int mySize = ++SIZE; //Compiler ERROR. //The final local variable SIZE cannot be assigned.
- Instance Variable (non static variable)
- Static Variable
- Local Variable
- Parameter Variable