• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Encapsulate

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really not sure what encapsulate means. As I understand that when data is encapsulate that means that data is hidden(like private) .. Right?
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's an article from JavaWorld that differentiates between encapsulation and information hiding: http://www.javaworld.com/javaworld/jw-05-2001/jw-0518-encapsulation-p2.html
Junilu
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
The article recommended by Junilu is a great article on this topic. I highly recommend reading it.
Good Luck,
-Dirk Schreckmann
 
reply
    Bookmark Topic Watch Topic
  • New Topic