Bắt đầu ngayBắt đầu miễn phí

Greet the name

You got feedback that users wanted to be greeted by name in the app. Let's add that functionality in our custom method.

Bài tập này là một phần của khóa học

Intermediate Java

Xem khóa học

Hướng dẫn bài tập

  • Give the correct type to the name argument of specificGreeter().
  • Use the argument inside the string to make it personalized.

Bài tập tương tác thực hành trực tiếp

Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.

class Greeter {
  // Give the correct type to the argument of the method
  static void specificGreeter(____ name) {
    // Call the correct variable given as an argument to the method
    System.out.println("Nice day to you, " + ____ + "!");
  }

  public static void main(String[] args) {
    String firstName = "Caleb";
    specificGreeter(firstName);
  }
}
Chỉnh sửa và Chạy Mã