• Post Reply Bookmark Topic Watch Topic
  • New Topic

two objects of the same class can access their private data  RSS feed

 
saurabh agr
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi every one,
can any body please explain this line---
"Two objects of the same class could access each other's private data."
i got this line from java ranch round up game but couldn't understand it.
please explain........... thanks
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "private" modifier restricts access to within the class -- not to specific instances. So all instances of the same class can access each other's private members.
 
Alpesh Gediya
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
marc weber wrote:The "private" modifier restricts access to within the class -- not to specific instances. So all instances of the same class can access each other's private members.


can you please elaborate on this.

What do you mean by all instances of the same class can access each other's private member?
 
Jatin Dhingra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alpesh Gediya wrote:

can you please elaborate on this.

What do you mean by all instances of the same class can access each other's private member?



Please see the code given by Rob above.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!