The latter keyword is used in several different contexts as a modifier, meaning that what it changes cannot be changed in a sense.
final classes
You will notice that a number of classes in the Java library are declared final, for example.
public final class String This means that this class will not be subclassed and tells the compiler that it can perform certain optimizations, otherwise it could not. It also provides some security and thread safety benefits.
The compiler will not give you a subclass of any class declared final. You probably won't want to or want to declare your own classes final, though.
final methods
You can also declare methods to be final. The method declared final cannot be overridden in a subclass. The syntax is simple, just put the final keyword after the access specifier and before the return type as follows:
public final String convertCurrency()
final fields
You can also declare fields final. This is not the same as declaring a method or class final. When a field is declared final, it is a constant that will not change and will not change. It can be installed once (for example, when the object is constructed, but after it it cannot be changed.) Attempts to change it will generate either a compile-time error or an exception (depending on how hidden the attempt is).
Fields that are final, static, and public are actually called constants. For example, a physics program may define Physics.c, the speed of light, as
public class Physics { public static final double c = 2.998E8; }
In the SlowCar class, the speedLimit field is likely to be both final and static, although it is private.
public class SlowCar extends Car { private final static double speedLimit = 112.65408;
final arguments
Finally, you can declare that the arguments to the method are final. This means that the method will not directly change them. Since all arguments are passed by value, this is not entirely necessary, but sometimes useful.