剛裝了eclipse,想寫個Java程序測試一下能不能用,結果一run就出現錯誤,Debug也是同樣的錯誤,錯誤內容為:the selection cannot be launched,and there are no recent launches.由於是初學者,對於Java完全不懂,就上網搜索發現說右鍵項目選擇run再選擇run as application,發現找不到這個。
以下是代碼
1 package test; 2 3 public class test { 4 5 static void main(String[] arg) 6 { 7 System.out.println("Hello World"); 8 } 9 }
發現需要加一個public在static前,並且String的S必須為大寫,並且main一定要拼寫正確。改正后的代碼如下
package test; public class test { public static void main(String[] arg) { System.out.println("Hello World"); } }
發現可以運行,成功輸出結果Hello World
2018.09.18