File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Private Variables 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Private Variables" Watch "Private Variables" New topic

Private Variables

Puja Sinha

Joined: May 25, 2011
Posts: 27
Can one object access a private variable of another object of the same class ?
Swastik Dey

Joined: Jan 08, 2009
Posts: 1528

Do you mean something like this?

If yes, the answer should be yes, because access specifier is specific to class, not specific to an object of the class.

Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3151

private variables can be accessed only with in the class where they are declared.
I would suggest you to write a small program to clear your queries. If you are still stuck you can post your code here and we can help you out. This way you can learn better and retain the concepts longer.

Mohamed Sanaulla | My Blog
jQuery in Action, 3rd edition
subject: Private Variables
jQuery in Action, 3rd edition