Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

what is delegation in java

you use an object of another class as an instance variable, and forward messages to the instance.
  
for example:
public class Shop {
	List<Banana> bananas = new ArrayList<>();

	public void add(Banana banana){
  		bananas.add(banana);
	}
}
 
PREVIOUS NEXT
Tagged: #delegation #java
ADD COMMENT
Topic
Name
3+9 =