Static Final Variable in Java

The Solution to Static Final Variable in Java is


Just having final will have the intended effect.

final int x = 5;

...
x = 10; // this will cause a compilation error because x is final

Declaring static is making it a class variable, making it accessible using the class name <ClassName>.x

~ Answered on 2011-09-27 02:48:58


Most Viewed Questions: