posted 15 years ago
((While I writted this it is possible that I got many more replays than few, maybe even six, or four, on which I am replaying))
Yes, yes, yes... Very much thank you on such a serious answers, and good. And fast. There is just this one moment: "So you instantiated it". I can use inherited protected member in a subclass, through inheritance as own subclas'es variable, but I didn't do that. It's what happened after instantiation. I used a protected member.
A) STAYS IN A PACKAGE AND SUBCLASS.
I know that I shouldn't be able to get protected member outside of both, of the subclass and outside of the package where it is declared protected.It should work through inheritance outside the package, (But it works through instantiation as well, in one case).
B) INSTANTIATING SUBCLASS.
I know that I can not instantiate (instantiate and use) Subclass and use protected member outside of the package of the Superclass. ( Except if I instantiate a Subclass in a Subclass'es method body - that's a question about, and it's happening outside of the superclass'es package, "the protected area")
C) SUBCLASSING ALL AROUND.
I know that by subclassing i can "drag" around the protected variable through the packages. (I think so), as long as I am doing it with the public classes around, and inheriting, but I can't do the same thing with instantiating here and there (except in a package from where it comes from, becaouse it is protected, AND in the subclass'es method body, wherever that package is)
1) I initialized a protected varible, and used it. Ouside*. ( but in a subclass's method body)
2) I can't do the same in any other class outside*.
*outside of the superclass'es package where the questioned protected member was declared as protected.
I can not connect statement 1 and statement 2 , here above, except through something like:
"In a subclass I can do whatever I want becaouse of the PROTECTED modifier somewhere else, which guarantiees me that I can use the PROTECTED variable in a subclass ALLWAYS, even through instantiation, not only through inheritance" ( and nevermind now the packages becaouse inheritance and keeping a variable safe is more important. )
So , my question is like:
Is this really so, as what I described?
(When I compile it, it behaves in this way which I described, but I am not used on talking about programming)
If it is understandable what I described, is this something that you know for?
Is this something that is common?
In a subclass I instantiated
a protected member