找不到Java应用程序的主要方法

问题描述 投票:-3回答:1

“错误:在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);
    }

}
java main
1个回答
0
投票

您只需要将main方法移出类测试,然后删除类测试。然后只要运行它,您就会得到正确的结果

© www.soinside.com 2019 - 2024. All rights reserved.