How do I Declare a Constant in Java?

Java does not directly support constants. However, a static final variable is effectively a constant.

The static modifier causes the variable to be available without loading an instance of the class where it is defined.

The final modifier causes the variable to be unchangeable.

Naming standards for Java constants

Java constants are normally declared in ALL CAPS.

Words in Java constants are normally separated by underscores.

Sample Java constant Declaration

public class MAX_UNITS {
   public static final int MAX_UNITS = 25;


Top 5 Free Networking Tools

Bookmark How do I Declare a Constant in Java?

Latest Blog Posts


English English GermanGerman SpanishSpanish FrenchFrench ItalianItalian PortuguesePortuguese RussianRussian DutchDutch
GreekGreek HindiHindi JapaneseJapanese KoreanKorean ChineseChinese Chinese (Simplified)Chinese (Simplified) ArabicArabic

Copyright 2009 Tech-FAQ. All rights reserved. Privacy Policy.