# How do I write constants names in Java?

Java 8Object Oriented ProgrammingProgramming

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 (_).

## Example

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);
}
}


## Output

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

Published on 05-Jan-2018 10:36:40