[英]Error:main method not found in the class, please define the main method
[英]Error: Main method not found in class Main, please define the main method
我需要有關主要方法的幫助,我收到此錯誤:編譯項目時:
Error: Main method not found in class Main, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
還嘗試了在線 Java 編譯器,但沒有運氣。
public class Main{
String yourname = "Ayush Sahu";
int mnumber = 25;
public void justtest(){
System.out.println("This is a test Method!!!");
}
}
class testing extends Main{
String fname = "Balamukunda";
String lname = "Sahu";
int age = 25;
public void testing(){
System.out.println("This is a test Method!!!");
}
public static void main(String[] args){
//Accessing the Data of Class: Main
testing myObj1 = new testing();
System.out.println(myObj1.yourname);
System.out.println(myObj1.mnumber);
myObj1.justtest();
//Accessing the Data of Class: testing
myObj1.testing();
System.out.println(myObj1.fname);
System.out.println(myObj1.lname);
System.out.println(myObj1.age);
}
}
如果要在 IDE 中運行,請在測試 class 中間右鍵單擊並在下拉菜單中找到運行 -> 運行應用程序並單擊它。 嘗試在單獨的文件中分隔每個 class。 所以你必須至少有兩個文件: Main.java和testing.java 。 我強烈建議您將 Camel Case 用於 class 名稱並尊重編碼標准(這意味着將testing更改為Testing甚至更好地更改為Test )。
如果沒有,您必須在 Manifest 文件中更改它或在 IDE 中找到運行配置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.