This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes help - private nested interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "help - private nested interface" Watch "help - private nested interface" New topic
Author

help - private nested interface

Yan Bai
Ranch Hand

Joined: Jul 21, 2002
Posts: 125
I am not quite understand what the advantage is with the private accessibility. Please give some code examples, Thanks!!


SCJP 1.4
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I just think that you will have to be a little more specific. That is, you provide the examples and we will think about them.
-Barry


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
The private members are not accessable from outside the class. So if you need to change a private member, all you have to wory about the other members of same class that are accessing it. So the code enhancement and maintenance is much easy. Compare that to a public member that could be called by any other member of any class. So to change that, you will have to possibly change all calling members. In nutshell, private modifier allows you to implement information hiding principle.
Thanks
Barkat
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Encapsulation: by making fields private and methods public the state of the object cannot be accessed directly by anyone. But through the methods. They are responsible for checking that changes in the state don't cause the object to go to an inconsitent state.
For instance, a color field in a traffic lights object cannot be set to pink.


SCJP2. Please Indent your code using UBB Code
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: help - private nested interface
 
Similar Threads
WA #1.....word association
How come public and friendly(default) access is allowed for top level class but not
displaying tag in jsp
Bullet-proof Class
What is the difference between these statements