Definitions of methods are empty
interface AComplenlnterface { void rnethodl() ; void method2 () ;
void methodM () ;
}
class AnAdapter implements AComplenlnterface { public void methodl () {};
public void method2 ()
}
class A extends AnAdapter {
public void method2 () {
ii the body of the method ii carries out sonie operations
}
}
class B extends AnAdapter {
public void method2 () {
ii the body of the method ii carries out sonie operations
}
public void method3 () {
ii the body of the method ii carries out some operations
}
}
For objects of the class a we want to invoke only the method method2 o, whereas for the objects of the class b we will invoke only methods method2 () and method3 ().
If there were no adapter we would be oblidged to supply definitions for all of the methods of the interface (for example methodio ()). not only for the ones we are interested in.
Applying an adapter we may supply definitions for exactly those methods we really need - this way we save time and are not forced to write unnecessary codę.