Originally posted by Shanel Jacob:
Hi, why is "protected" an illegal modifier then? I know Sun Java say so but I'd like to know the rationale behind it. Thank you.
You kind of answered this yourself in your original post.
There wouldn't be a point.
public: the class is available outside of the package
private: ?
package: the class is only availalbe within the package.
protected: ?
If you think about it, private, package and protected would all achieve the same goal - restricting access to the class to within the same package. Since packages can't be "inherited", there is no use for protected. And the default access modifier (package) does not allow external access, so private is made redundant.
I would gather that there are only two (public/package) in order to keep it as simple as possible.