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.
Latihan ini adalah bagian dari kursus
Intermediate Java
Petunjuk latihan
- Give the correct type to the
nameargument ofspecificGreeter(). - Use the argument inside the string to make it personalized.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
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);
}
}