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 Encapsulation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Encapsulation " Watch "Encapsulation " New topic


Sham Grandhe
Ranch Hand

Joined: Dec 16, 2003
Posts: 73
hai friends,

plz send a good definition for encapsulation.
michelle anderson

Joined: Sep 13, 2004
Posts: 3
Encapsulation is a technique for hiding data and behavior within a class;it helps you write clean, modular software.

Hope this helps.
marc weber

Joined: Aug 31, 2004
Posts: 11343

In practice, encapsulation basically means making variables private and allowing them to be accessed and/or manipulated only through methods.

This is particularly useful where polymorphism is concerned. See thread
[ September 13, 2004: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
"Information hiding" is a concept that I Googled once and found references back into the 1970s. It's key to good modularity in procedural or OO languages. A C module can hide its algorithms, but an object can also hide and protect its data so thoroughly that no external chunk of code can mess it up. Encapsulation is "improved information hiding." (Not meant to be a closed definition ... does it mean more to you?)

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Sham Grandhe
Ranch Hand

Joined: Dec 16, 2003
Posts: 73
thank you friends this will help me a lot.

with regards
I agree. Here's the link:
subject: Encapsulation
jQuery in Action, 3rd edition