in the following code is there anyway i can call the new method called sizzle and get it to run? if it is not possible then could i please know the use of using anonymous classes?
class Popcorn {
public void pop(){
System.out.println("pop corn");
}
}
class Food {
Popcorn p = new Popcorn(){
public void pop(){
System.out.println("anonymous popcorn");
}
public void sizzle(){
System.out.println("fdsaf");
}
};
public static void main(
String ar[]){
Popcorn p = new Popcorn();
p.pop();
p.sizzle();// does not compile. is there a way to get it to work?
}
}
if who i am is what i have, and what i have is lost, then who am i?<br /> <br />SCJP 5.0<br />SCWCD 1.4<br />SCBCD preparing