What Field Modifier final Means

This section looks at final, which makes something constant. Why was the word “const” or “constant” not chosen? Because “final” can also be applied to methods, as well as data, and the term “final” makes better sense for both.

A class or a class member (that is, a data field or a method) can be declared final, meaning that once it is given a value it won't change. We will look at what it means for a class or a method not to change in Chapter 8. A couple of final data declarations are:

final static int myChecksum = calculateIt();final Timestamp noon = new Timestamp(12, 00, 00);final int universalAnswer = 42;

When a reference variable is declared final, it means that you cannot change that variable to point ...

Get Just Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.