62,620
社区成员
发帖
与我相关
我的任务
分享
package ttgive;
interface MyInterface
{
public void show();
}
public class test
{
public static void main(String[] agrs)
{
//定义匿名内部类并且创建起对象
MyInterface a=new MyInterface()
{
//实现其父类的方法
public void show()
{
System.out.println("恭喜你创建了匿名类,该类实现了MyInterface接口");
}
};
//访问匿名内部类实现的 方法
a.show();
}
}
interface Flyer();
Flyer f=new Flyer();Flyer f=new SeaPlane();
Sailer s=new SeaPlane();