Following example shows how to use simple delegation in Java.
Java Code:
class ClassA {
	     void methodA() { System.out.println("CLassA: methodA()"); }
	     void methodB() { System.out.println("ClassA: methodB()"); }
}
	 
class ClassB {
	     ClassA obj = new ClassA();
	 
	     void methodA() { obj.methodA(); }
	     void methodB() { obj.methodB(); }
	     
	     // code goes here ...
}
	 
public class MainClass {
	     public static void main(String[] args) {
	         ClassB obj = new ClassB();
	         obj.methodA();
	         obj.methodB();
	     }
}