Tuesday, 7 April 2009

The final keyword in Java can be applied to almost anything

The final keyword can be applied to many types of "code objects" in Java, classes, methods and variables. For example:

final class - implies that the class that cannot be subclassed
final method - implies that the method that cannot be overriden
final value - implies that the value that cannot be reassigned (but is NOT, I repeat NOT, immutable)

final has nothing to do with immutability. It also has no meaning in packages (unless I suppose all the containing classes are final).

No comments: