posted 18 years ago
The code can be found on page 467 of K&B 1.4:
class Food{
Popcorn p = new Popcorn() {
public void pop() {
System.out.println("anonymous popcorn");
}
};
}
It mentioned that an anonymous class is created and it is actually a SUBCLASS of Popcorn. I can understand this part.
Next on page 473 - Argument-Defined Anonymous Inner Class
b.doStuff(new Foo() {
public void foof() {
System.out.println("foofy");
} //end foof method
}); //end inner class def, arg, and end statement
My question is whether the anonymous class created within the arg, is a SUBCLASS of Foo?