aspose file tools*
The moose likes Beginning Java and the fly likes Encapsulation in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Encapsulation in java " Watch "Encapsulation in java " New topic
Author

Encapsulation in java

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

Here is a defination of Encapsulation from a site


Encapsulation refers to the bundling of data with the methods that operate on that data, and also some say that ENcapsulation is data hiding .

From this i understand that Encapsulation is nothing but a java bean with private properties and public methods .

Please guide me here .


Save India From Corruption - Anna Hazare.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2409
    
    7

encapsulation? Your definition is correct. It is data hiding because the class uses public getters/setting to retrieve/assign "private" variables. And the class is practically a JavaBean.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you very much
Ulrika Tingle
Ranch Hand

Joined: Nov 24, 2009
Posts: 92
Ravi Kiran V wrote:
From this i understand that Encapsulation is nothing but a java bean with private properties and public methods .


In OO, encapsulation is a little more than that. When you encapsulate something you get an inside and an outside. The outside is called a data abstraction, or the type. The inside is called information hiding, or the implementation. So in principle encapsulation is the separation of a visible type from a hidden implementation, or the division of something into "what" you can see and use, from "how" it's done. Most importantly the type and the implementation become independent of each other and can be changed separately.

The main units of encapsulation in Java is the class, the enum and the interface (each with somewhat different encapsulation properties). The type is the signature and behaviour of all non-private methods and fields of these language elements. The implementation is the code inside including private methods and fields.

Encapsulation is very important in Java. It's at the very heart of OO programming. Defining appropriate types and cleverly hiding implementation is the process that drives the design and development of Java programs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Encapsulation in java