This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

Help on private access

 
George Jin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class A
{
private int i;
public void modifyOther(A a1)
{
a1.i = 20; //1
}
}
Why a1 can access the private member i? Is it because this method within Class A?

Thanks
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is. Have you tried The Java Tutorial ?
 
praveena kuppachi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
A method or a variable that is declared private i s not accesible outside the class.Thats is only the members belonging to the class can acces it.it can be used by the instance of the class that declares it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic