简体   繁体   English

Java的主要方法 应用未找到

[英]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; "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);
    }

}

you just need move the main method out of class test, and delete the class test.您只需将 main 方法移出 class 测试,并删除 class 测试。 Then Just run it, you will get correct result然后运行它,你会得到正确的结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM