This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes protected access modifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "protected access modifier" Watch "protected access modifier" New topic
Author

protected access modifier

devika cha
Greenhorn

Joined: Dec 17, 2003
Posts: 23
A protected instance variable can be accessed by subclass in same package or from different package by inheritance.

My question is how to access protected instance var in the subclass that is in same package .
thank you.
[ edited to preserve formatting using the [code] and [/code] UBB tags and to format the code -ds ]
[ January 09, 2004: Message edited by: Dirk Schreckmann ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Sulakshana,
You have the right idea. In the example you posted, the dep class is not a sublcass of the Test class. It is extending a class called ThreadTest.

[ January 08, 2004: Message edited by: Jeanne Boyarsky ]

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

protect from what?
 
 
subject: protected access modifier
 
Similar Threads
Cloning
private constructors
confusion of protected
accessing protected members
protected modifier