This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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
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.