wood burning stoves
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
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: 1579

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: 3152

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
I agree. Here's the link: http://aspose.com/file-tools
subject: Private Variables
It's not a secret anymore!