0

I know this might be thought of as a duplicate question, but I think my question is a bit different from the previous questions.

The difference between public and protected members is that a public member acts as a protected member on in that it can be accessed from the world but a protected member cannot.

What does the term world mean? Does it mean from outside the class? If so how?

Is it by using the class name? Or they can be accessed by using the variable/method name directly without the current class being a subclass?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
coder123
  • 841
  • 1
  • 7
  • 19
  • a protected member can be accessed from a subclass – Maurice Perry Jan 04 '18 at 12:32
  • The definition of 'world' is even given in the [Java tutorial](https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html): _"The fourth column [world] indicates whether all classes have access to the member."_ – Mark Rotteveel Jan 04 '18 at 12:36

1 Answers1

1

Okay, the word "world" means that it can be accessed from anywhere inside the project (no matter if they are in the same package). However the protected members means that they can only be accessed from other classes inside the same package. Sources

Alex Cuadrón
  • 638
  • 12
  • 19