interface Contents
{
void go(){};
}
public class Test1 {
public Contents con()
{
return new Contents()
{
public void go()
{
System.out.println("I got it");
}
};
}
public static void main(String [] args)
{
Test1 t = new Test1();
Contents c = t.con();
c.go();
}此处匿名内部类中的go()方法为什么一定要写明是public的(不然不能运行)
|