Loading

摘要: View Code interface Inter{ void show();}class Outer{ //补足代码(用匿名内部类完成)}public class OuterTest { public static void main(String[] args) { Outer.method().show(); }} 阅读全文
posted @ 2012-06-11 23:03 The Mechanic 阅读(136) 评论(0) 推荐(0) 编辑
摘要: /* 匿名内部类: 其实就是内部的简化形式。 前提: 内部类必须继承或者实现外部类或接口。格式: new 父类&接口(){}; 其实就是一个子类对象。有点胖。为什么要有匿名内部类? 提高开发效率*/abstract class Test //Test 能不能创建对象? 不能 因为有抽象方法 -->抽象类的子类能创建对象,因为它覆盖来了父类方法{ abstract void show(); }class Outer{ int x = 3; //1定义内部类 class Inner { void show() { System.out.printl... 阅读全文
posted @ 2012-06-11 22:55 The Mechanic 阅读(99) 评论(0) 推荐(0) 编辑