Rob Prime wrote:Let's consider what would happen.
If he class is private, that means that nothing outside the class can see it. Oops. The class has just been rendered completely useless, being completely isolated from the rest of the code since no other code can see it.
If the class is protected, that means that only classes in the same package (default access) and sub classes can see it. But for a class to be able to sub class it, they must see it first. And they can't until they are sub classes. It's like saying "you can enter my house, but only if you're already in it". As such, the protected adds nothing that default doesn't already offer.
If you want to allow classes in the same package to be able to create instances of, for example, class A and also subclass class A but only allow classes outside of the package to subclass class A (i.e not create instances of class A), wouldn't that be an argument to allow protected classes?