
使用 Eclipse 寫 class 的時候,測試時如果出現 The selection cannot be launched, and there are no recent launches. 如下圖:
這代表你的 class 裡面沒有寫 main function,請補上 main function 就可以了。
一定會有人想說,我是要寫 class,裡面本來就沒有 main 了阿,可是 Eclipse 就是要阿,所以你可以用以下的寫法:
class test
{
public static void showMessage()
{
System.out.println("這是個測試...");
}
public static void main(Strgin args[])
{
showMessage();
}
}
文章標籤
全站熱搜

