Skip Top Navigation Bar

Using Constants in Java

There are times when we don't want a value to change while the program is running. In these cases, a constant can be used. A constant is a value that does not change once it is assigned a value. We use the keyword final in front of the data type when we create a constant and assign it the constant value. For example:

final double pi = 3.14;

Resources

Next Learn Tutorial

Learn: Introduction to Using enum