日期:2014-05-20  浏览次数:20687 次

又一个JAVA问题(没有运行结果)
//: innerclasses/ClassInInterface.java
// {main: ClassInInterface$Test}

public interface ClassInInterface {
  void howdy();
  class Test implements ClassInInterface {
    public void howdy() {
      System.out.println("Howdy!");
    }
    public static void main(String[] args) {
      new Test().howdy();
    }
  }
}
运行提示信息:
Error: Main method not found in class ClassInInterface, please define the main method as:
   public static void main(String[] args)

------最佳解决方案--------------------
楼主把这个方法定义到接口下的类Test里了。不在ClassInInterface 下面,所以报错。
楼主可以运行:
java ClassInInterface$Test
会出来结果。
Howdy!

------其他解决方案--------------------
没这种搞法……
------其他解决方案--------------------
说土一点,你一边还没定义好,一边就在用它了,怎么可能?
------其他解决方案--------------------
谢谢朔方征雁 !