[英]Error: Main method not found in class mainGUI, please define the main method as: public static void main(String[] args)
[英]java Hello World Error: Main method not found in classname, please define the main method as: public static void main(String[] args)
我不明白為什么我在下面的代碼中收到錯誤:
公共 class Lab1HW { 公共 static 無效主(字符串 [] 參數) {
System.out.println("Computer Science, Yes!!!!");
}
}
執行以下步驟:將代碼編寫為:
public class Lab1HW{
public static void main(String[] args){
System.out.println("Computer Science, Yes!!!!");
}
}
然后使用與 class 名稱相同的名稱保存文件。 在你的情況下 Lab1HW.java 那么你必須編譯並運行.. output 將是
Computer Science, Yes!!!!
您的代碼看起來不錯,只需嘗試以這種方式編寫它或首先嘗試在在線編譯器上運行它。
public class Lab1HW{
public static void main(String[] args){
System.out.println("Computer Science, Yes!!!!");
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.