Slightly related to my other question: What is the difference between the following:
private class Joe protected class Joe public class Joe class Joe
Once again, the difference between the last 2 is what I’m most interested in.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A public class is accessible to a class in any package.
A class with default access (
class Joe) is only visible to other classes in the same package.The private and protected modifiers can only be applied to inner classes.
A private class is only visible to its enclosing class, and other inner classes in the same enclosing class.
A protected class is visible to other classes in the same package, and to classes that extend the enclosing class.