Constants | Heaton Research

Constants

Get the entire book!
Java for the Beginning Programmer

You can also designate a variable as constant. A constant variable may not change its values. Constants are useful to define common numbers, such as pi. To create a constant variable put the keyword final in front of the variable. For example, the following line creates a pi constant.

final double pi = 3.14159265;
Copyright 2005-2008 by Heaton Research, Inc.