MulaiMulai sekarang secara gratis

Greetings

Every time the program reaches its main() part, you want it to greet the user by wishing them a good day.

Latihan ini adalah bagian dari kursus

Intermediate Java

Lihat Kursus

Petunjuk latihan

  • Insert the static keyword before the custom method.
  • Call the custom method genericGreeter() inside main().

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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
    ____();
  }
}
Edit dan Jalankan Kode