Carey Brown wrote:Protected is like private with the exception that an immediately inherited subclass also has access.
I don't think so since a source file (a .java file) can have code of another class which doesn't have access to the private member of another class defined in the same source file.Stephan van Hulst wrote:An overview:
private: Only code within the same source file can access the member.
Ganesh Patekar wrote:Rather I would say private members are directly accessed only within the class they are declared in.
That JLS section, example 6.6.5 wrote:A private class member or constructor is accessible only within the body of the top level class (§7.6) that encloses the declaration of the member or constructor. It is not inherited by subclasses.
Stephan van Hulst wrote:I'm pretty sure that includes the bodies of nested classes though.
There are three kinds of actuaries: those who can count, and those who can't.
The variables are visible within a static nested class, but not accessible because of another rule that code in a static context cannot access instance members. Try it and see what sort of compiler error message you get.Liutauras Vilda wrote:. . . except static nested classes.
Agreed I was wrong. I didn't think of private members declared in inner class.Stephan van Hulst wrote:an enclosing class can access private members of a nested class.
Ganesh Patekar wrote:
Agreed I was wrong. I didn't think of private members declared in inner class.Stephan van Hulst wrote:an enclosing class can access private members of a nested class.
YesLiutauras Vilda wrote:I think nested inner class can access enclosing classes private members
No, enclosing class can access private members of inner class.not other way round.
Yes It is all about wording that's why hats off to those who document JLS.But I might misunderstanding the wording.
RTFJD (the JavaDocs are your friends!) If you haven't read them in a long time, then RRTFJD (they might have changed!)
Campbell Ritchie wrote:their rule is very simple:
That is not what I meant to say. I must have been unclear about it; sorry.Mike Simmons wrote:. . . the "it" variable . . . would be in scope after the end of the for statement, which is not the case. . . . .
kevin Abel wrote:How do others on the Ranch know when they read the last post without having to keep opening posts?
To add to what Carey said, in “table” view of all the threads, the icon in the “last post” column changes colour similary, and clicking the yellow icon takes you directly there.kevin Abel wrote:. . . How do others on the Ranch know when they read the last post . . .?
Try clicking the “Notify when a reply is posted” box when you post something, or click the “Watch Settings” button near the bottom left.Is there a better way to organize myself with this? . . .
My apologies; somebdoy pointed out it was Ron who said thatAn hour or two ago, I wrote:. . . To add to what Carey said . . ..
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|