開始使用免費開始

打招呼

每次程式進入 main(),你都希望它向使用者問候,祝他們有美好的一天。

本練習屬於課程

Java 中級

檢視課程

練習說明

  • 在自訂方法前加上 static 關鍵字。
  • main() 內呼叫自訂方法 genericGreeter()

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

class Greeter {
  // Enter the keyword to be able to access it in main
  ____ void genericGreeter() {
    System.out.println("Nice day to you !");
  }

  public static void main(String[] args) {
    // Call the above function to have the program greet you
    ____();
  }
}
編輯並執行程式碼