黑马程序员技术交流社区

标题: 内部类补全代码练习 [打印本页]

作者: jekyll    时间: 2015-9-25 15:47
标题: 内部类补全代码练习
  1. class Test2_NoNameInnerClass {
  2.         public static void main(String[] args) {
  3.                 Outer.method().show();
  4.         }
  5. }

  6. interface Inter {
  7.         void show();
  8. }

  9. class Outer {
  10.         //补齐代码
  11.         public static Inter method(){
  12.                 return new Inter() {
  13.                         public void show() {
  14.                                 System.out.println("Hello World!");
  15.                         }
  16.                 };
  17.         }
  18. }
复制代码





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2