Monday, April 7, 2008

How to prevent subclassing!

1. By declaring class as final

public final class Parent{
}


2. By having only private constructors. Super class constructors should be visible in order to subclass.

private Parent(){
}

No comments: