This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Help on private access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Help on private access" Watch "Help on private access" New topic

Help on private access

George Jin

Joined: Oct 18, 2002
Posts: 4
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?

Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Yes it is. Have you tried The Java Tutorial ?

SCJP2. Please Indent your code using UBB Code
praveena kuppachi

Joined: Jan 24, 2003
Posts: 15
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 can be used by the instance of the class that declares it
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Help on private access
It's not a secret anymore!