Java Tutorial/Class Definition/Final Class
Версия от 17:44, 31 мая 2010; (обсуждение)
Final Classes
You can prevent others from extending your class by making it final using the keyword final in the class declaration.
final class FinalClass{
}
Using final to Prevent Overriding
class A {
final void meth() {
System.out.println("This is a final method.");
}
}
class B extends A {
void meth() { // ERROR! Can"t override.
System.out.println("Illegal!");
}
}