Please always say where such information comes from. That definition is incorrect, anyway. The correct definition is in the Java® Language Specification (=JLS).Nyeng Gyang wrote:. . . accessible from (1) All classes that are in the same package as class A and (2) All classes that are subclasses of class A. . . .
It makes protected access hard to understand.What do you think about this?
Some people, when well-known sources tell them that fire will burn them, don't put their hands in the fire.
Some people, being skeptical, will put their hands in the fire, get burned, and learn not to put their hands in the fire.
And some people, believing that they know better than well-known sources, will claim it's a lie, put their hands in the fire, and continue to scream it's a lie even as their hands burn down to charred stumps.
I think this is that thread.Tim Holloway wrote:. . . another thread.
Did you (NG) read the JLS section? Such calls don't constitute part of the object.. . . you have an instance of "A" named "a" and you're trying to invoke the forbidden method using "a" as the method target.
. . . that does constitute implementing the object.If the target of the protected method had been "this" or "super", . . .
Beware: it takes a lot of experience to work out whether the site you found provides really good information or a load of old rubbish.Nyeng Gyang wrote:. . . Googling this topic . . .
I quote the Java™ Tutorials all the time, but I am aware of places where they differ from the official JLS definitions. Remember the JLS is definitive, or take shortcuts for the sake of clarity. The people who wrote the Java™ Tutorials were aware of that. They explain themselves like this:-The Java™ Tutorials . . .
I think it might be better to call their definition incomplete than wrong.The Same Tutorials page as before wrote:Many of the examples in the tutorial . . . not recommended for production code.
Campbell Ritchie wrote:I think it might be better to call their definition incomplete than wrong.
Some people, when well-known sources tell them that fire will burn them, don't put their hands in the fire.
Some people, being skeptical, will put their hands in the fire, get burned, and learn not to put their hands in the fire.
And some people, believing that they know better than well-known sources, will claim it's a lie, put their hands in the fire, and continue to scream it's a lie even as their hands burn down to charred stumps.
I'm so happy! And I wish to make this tiny ad happy too:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
|