How do I write constants names in Java?

While writing the name of the constants it is suggested to

  • write all the letters in upper case.
  • If constant contains more than one word they should be separated by underscore (_).


Live Demo

public class ConstantsTest {
   public static final int MIN_VALUE = 22;
   public static final int MAX_VALUE = 222;
   public static void main(String args[]) {
      System.out.println("Value of the constant MIN_VALUE: "+MIN_VALUE);
      System.out.println("Value of the constant MAX_VALUE: "+MAX_VALUE);


Value of the constant MIN_VALUE: 22
Value of the constant MAX_VALUE: 222

Updated on: 30-Jul-2019


Kickstart Your Career

Get certified by completing the course

Get Started