Wednesday, August 17, 2016

Java anonymous inner class example using interface


package Interface;

interface Eatable {
void eat();
}

class TestAnnonymousInner1 {
public static void main(String args[]) {
/* Eatable e = new Eatable() {
public void eat() {
System.out.println("nice fruits");
}
};
e.eat();
*/
new Eatable() {
public void eat() {
System.out.println("nice fruits");
}
}.eat();
}
}