File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 29220
    
135

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?
 
Consider Paul's rocket mass heater.
 
subject: protected access modifier
 
Similar Threads
confusion of protected
protected modifier
private constructors
Cloning
accessing protected members