I think perhaps this question might fit well in the Java Ranch forum or maybe we could just get one of the Sheriffs to clarify what #208 is...or we can run the game until we get it...that's what I think I'll do in the meantime. Paul
Joined: Jun 08, 2000
Can one object access a private variable of another object of the same class? <h6>it only took me about 2 minutes to find it...but I got a lot of the questions wrong in the meantime</h6> The answer to this question is Yes, it can. I think the explanation of this answer in the round-up is that the access is granted to the class, not the object... To explain that a little further, any object created from a specific class has access to the private variables of any other object created from that class. Take a look:
Even though there are 2 different objects here (referenced using x and b) b is still able to access the private variable of object x. Why? Because the objects referenced by x and b were both created from the same class (Sharing), and objects created from the same class have access to each other's privates ( get your mind out of the gutter, you know what I mean!). I hope that helps...send me an e-mail if you want a little clarification and I'll post it up here.
[This message has been edited by Paul Caudle (edited November 13, 2000).]
Joined: Nov 10, 2000
Thanks all...after I re-read the question I understood what it was talking about...