| Author |
Protected Keywords - More Info about it
|
Nelly Verccety
Greenhorn
Joined: Feb 16, 2006
Posts: 8
|
|
I am analyzing java code using QJ-Pro and it comes with the next message: Do not define protected members in classes that are not part of a named package. Anyone know what that means? The line that is refering too is the following: protected Panel getPanel() {return this;} What do I need to know about protected keyword before I use it?
|
 |
Nelly Verccety
Greenhorn
Joined: Feb 16, 2006
Posts: 8
|
|
|
Other thing, when is protected best used and where should be placed it so that its clear and will not break encapsulation?
|
 |
Aum Tao
Ranch Hand
Joined: Feb 14, 2006
Posts: 210
|
|
Protected members are accessible in the same class or its subclasses. If accessed from subclass , the instance should be of the class from where the protected member is being accessed or its subclass. The package may differ in this case.
|
SCJP 1.4 85%
|
 |
 |
|
|
subject: Protected Keywords - More Info about it
|
|
|