File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Encapsulate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Encapsulate" Watch "Encapsulate" New topic


Mike Shn
Ranch Hand

Joined: May 26, 2001
Posts: 149
I really not sure what encapsulate means. As I understand that when data is encapsulate that means that data is hidden(like private) .. Right?
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
Yes. It means to keep hidden things you don't want the outside world to know about, and just provide a public API (application programming interface) for the outside world to use.
That way, since you've kept your internal implementation private, you are free to change it later and no one has to know about that change. As long as the API stays the same, users of your class will continue to use your object just as they always have.

SCJP 1.4
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Here's an article from JavaWorld that differentiates between encapsulation and information hiding:
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
The article recommended by Junilu is a great article on this topic. I highly recommend reading it.
Good Luck,
-Dirk Schreckmann

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Encapsulate
It's not a secret anymore!