“错误:在com.oops.inheritance类中找不到主要方法,请将该主要方法定义为:公共静态void main(String [] args)或JavaFX应用程序类必须扩展javafx.application.Application”包com.oops;
public class inheritance {
int model_no;
String name;
int battery;
String release;
public inheritance(int model_no, String name, int battery, String release) {
super();
this.model_no = model_no;
this.name = name;
this.battery = battery;
this.release = release;
}
@Override
public String toString() {
return "inheritance [model_no=" + model_no + ", name=" + name + ", battery=" + battery + ", release=" + release + "]";
}
}
class test {
public static void main(String[] args) {
inheritance in = new inheritance(101, "Samsung", 4000, "15 September 2019");
System.out.println(in);
}
}
您只需要将main方法移出类测试,然后删除类测试。然后只要运行它,您就会得到正确的结果