打招呼
每次程式進入 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
____();
}
}