This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "protected access modifier" Watch "protected access modifier" New topic

protected access modifier

devika cha

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
author & internet detective

Joined: May 26, 2003
Posts: 32818

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 ]

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

protect from what?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: protected access modifier
It's not a secret anymore!