Reputation: 225
How do I protect classes which are used in another package (from classes which don't inherit) to be instantiated from the outside? Is this even possible in Java?
Upvotes: 0
Views: 158
Reputation: 2473
make constructor protected
public class ProtectClass {
protected ProtectClass() {
// TODO Auto-generated constructor stub
}
}
Upvotes: 1
Reputation: 938
Well, abstract classes can't be instantiated, but that may not be what you're looking for... I've never heard of this being possible.
Upvotes: 0