Prev Next

Java / Class Variables (Static Variables)

How do I define a constant?

Posted on Apr 1, 2016 by Senthil Kumar.

The variable should be declared with static and final modifiers. static ensures that only one variable exists for all instances of the class and final makes its value not changeable once initialized.

static final int MAX_HEIGHT = 50;

More Related questions...

Show more question and Answers...


Comments & Discussions