[英]Main method of Java Application is not found
"Error: Main method not found in class com.oops.inheritance, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application " package 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 方法移出 class 測試,並刪除 class 測試。 然后運行它,你會得到正確的結果
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.