aspose file tools*
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


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 "Rules round up question doubt" Watch "Rules round up question doubt" New topic
Author

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
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

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
 
Consider Paul's rocket mass heater.
 
subject: Rules round up question doubt
 
Similar Threads
Statement Doubt
JavaRanch question #208: private variable
Doubt regarding data encapsulation
doubt from ranch roundup
doubt