Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can objects of sam class can access each others private variables?if yes then how ?

 
Waez Ali
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this question when i was playing that roundup game
It is (#80)th question & it says yes it is possible.
please somebody make me understand this concept with some example i m new to javaranch....
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, and a common example would be the equals method.



This is a common example. Because we are in the same class, even though it is different instances, we can access the private fields.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic