jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Rules round up question doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Rules round up question doubt" Watch "Rules round up question doubt" New topic

Rules round up question doubt

Siri Naray
Ranch Hand

Joined: May 19, 2006
Posts: 105
Can one object access the private variable of another object of the same class?

Private means private to the class not object. So 2 objects of teh same class can access each other private data.

My doubt is.. how can an obj access another objects data first place?
What does this statement mean?? If teh answer is right can anyoen give an example code for this??
Sorry if its a primitive question.
Thank you sirisha

If you worry you cannot work... If you work you need not worry
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

When you call the method "m" of class "C", you have to supply another instance of "C" as the argument. "m" takes the value of "i" from the other instance of "C", and sets its own variable "i" to that value plus one.

[Jess in Action][AskingGoodQuestions]
Siri Naray
Ranch Hand

Joined: May 19, 2006
Posts: 105
Thank you
I agree. Here's the link: http://aspose.com/file-tools
subject: Rules round up question doubt
It's not a secret anymore!