final Variables

A final variable, also called a “constant,” is a variable whose value you can’t change after it’s been initialized. For example, you might use a final variable to define a constant value, such as pi. To declare a final variable, you add the final keyword to the variable declaration, like this:

static final int WEEKDAYS = 5;

Although it isn’t required, adding the static keyword is common for final variables.

tip.eps Using all capital letters for final variable names is a common convention. That way, you can easily spot the use of final variables in your programs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset