GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Delegation 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 "Delegation in Java " Watch "Delegation in Java " New topic
Author

Delegation in Java

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi


I think that in Java the word delegation means it is HAS - A relationship .

and Delegation is equal to Composition or Aggregation .

Please correct me if i am wrong .

Please let me know what is meant by Delegation in java ??

Save India From Corruption - Anna Hazare.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3833

That is, you wrap a particular type of object and pass (delegate) method calls to the wrapped object, this is the fundamental for the Decorator pattern. And yes that's achieved through a HAS-A relationship.

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213
No, You cannot say Delegation is equal to Composition or Aggregation.

As Vijitha Kumara said, Delegation is achieved using Composition/Aggregation.


SCJP 6, SCWCD 5, SCBCD 5
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Delegation is achieved using Composition/Aggregation.


Thank you very much . This line explains .
Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
you can use delegation when you want to use another class's functionality,as is, without changing that behavior at all.
In another words,if you need to use functionality in another class,but you don't want to change that functionality,consider using delegation instead of inheritance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Delegation in Java