Hi folks correction in marcus tutorial........ The protected modifier is a slight oddity. A protected variable is visible within a class, and in sub classes, the same package but not elsewhere.<And also in classes in other packages which subclass this class thru handle of the class in other package ........>The qualification that it is visible from the same package can give more visibility than you might suspect. Any class in the same directory is considered to be in the default package, and thus protected classes will be visible. This means that a protected variable is more visible than a variable defined with no access modifier
Rolf Weasel
Ranch Hand
Joined: Feb 26, 2000
Posts: 82
posted
0
A protected variable is supposed to have more accessibility than default. default access means package visibility, whereas protected access includes both package visibility and visibility in all subclasses, including subclasses in other packages. the term protected sounds more restrictive than it really is!
May the Moose be with you.
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
Mahen- it looks like the text you've quoted is an exact quote from Marcus' tutorial as it appears currently. Are you saying that you think it should be corrected? Or that it was corrected recently? Or something else? The text looks good to me - what exactly is your question?
"I'm not back." - Bill Harding, Twister
Tony Alicea
Desperado
Sheriff
Joined: Jan 30, 2000
Posts: 3219
posted
0
I recommend the section called "What <CODE>protected</CODE> really means" in the book "The Java Programming Language" 2nd. ed. by Ken Arnold and James Gosling, page 63. I assure you, <CODE>protected</CODE> is the least straightforward of access specifiers. To demonstrate it, requires an inter-package code example that I can't find at the moment: It can't be demonstrated writing and executing code on the same package. That is, the example requires a class X in package A to be a subclass of class Y in package Z where the superclass has a <CODE>protected</CODE> member.
Tony Alicea Senior Java Web Application Developer, SCPJ2, SCWCD
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.