This question already has an answer here:
Java has private, protected, and public access modifiers. Can you explain the accessibility scope of these modifiers.
How can I access a protected member within a different package?
This question already has an answer here:
Java has private, protected, and public access modifiers. Can you explain the accessibility scope of these modifiers.
How can I access a protected member within a different package?
For better understanding you need to see this
Here the important difference is between
Default
andprotected
.Default: Never accessible outside the package
Protected: Only accessible outside the package, if and only if the class is a subclass
Please see this for further details.
Edit: As your question's answer is also the same that
You can access the protected member by make your class a sub class of the class , in which protected member is defined