我正在学习如何在YouTube视频后实现界面。他运行我发布的代码,然后运行相同的代码。他的编译和打印时我给了我错误代码:
Machine startedException in thread "main" java.lang.NoClassDefFoundError:
Person
at App.main(App.java:9)
Caused by: java.lang.ClassNotFoundException: Person
at java.base...(etc.)
这是因为我在运行Eclipse时运行jGrasp吗? 教程程序的代码如下:
public class App{
public static void main(String[] args){
Machine mach1 = new Machine();
mach1.start();
Person person1 = new Person("Bob");
person1.greet();
Info info1 = new Machine();
info1.showInfo();
Info info2 = person1;
info2.showInfo();
}//end of main class
}//end of App class
public class Machine implements Info{
private int id = 7;
public void start(){
System.out.print("Machine started");
}
public void showInfo(){
System.out.println("Machine id is " + id);
}
}//end of machine class
public class Person implements Info{
private String name;
public Person(String name){
this.name = name;
}
public void greet(){
System.out.println("Hello there");
}
public void Info(){
System.out.print("Person name is " + name);
}
}//end of person class
public interface Info{
public void showInfo();
}//end of interface