我编了几个程序,它都告诉我 thread in main no such method erro :main
搞不明白,多谢!运行通不过,编译可以通过,望指教!
interface Machine
{
void run();
}
class Person
{
public void run()
{
System.out.println("Person run.");
}
}
class Robot extends Person
{
class RobotHeart implements Machine
{
public void run()
{System.out.println("heart run.");
}
}
Machine getmachine()
{
return new RobotHeart();
}
}
class Test
{
public static void main(String[] args)
{
Robot r=new Robot();
Machine m=r.getmachine();
m.run();
r.run();
}
}
參考答案:我在我电脑上可以运行啊,你的程序是对的,可能你运行时参数打错了,
javac Test.java
java Test
输出如下:
heart run.
Person run.