黑马程序员技术交流社区

标题: 按照要求不全代码 [打印本页]

作者: 他的好    时间: 2016-7-1 22:30
标题: 按照要求不全代码
interface Inter { void show(); }
                class Outer { //补齐代码 }
                class OuterDemo {
                        public static void main(String[] args) {
                                  Outer.method().show();
                          }
                }
                要求在控制台输出”HelloWorld”
作者: zhoubinjian    时间: 2016-7-1 23:42
class Outer {         static int x=3;                  static class Inter         {                 void show()                 {                 System.out.println("HelloWorld");                 }         }         static void method()         {                 new Inter();         } }
作者: ylca    时间: 2016-7-2 03:42
class Outer {
//补齐以下代码
        public static Inter method() {
                return new Inter() {                    // 重写该接口的子类对象
                        @Override
                        public void show() {
                                System.out.println("HelloWorld");
                        }
                };
        }
        
}





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