Monday, March 28, 2011

Java final methods

The final keyword prevents a method from being overridden in a subclass, and is
often used to enforce the API functionality of a method.

class SomeClass{
public final void finalMethod() {
System.out.println("One thing.");
}
}

It's legal to extend SuperClass, since the class isn't marked final, but we can't
override the final method finalMethod()

No comments:

Post a Comment