You are working on a Java application for greeting users. You have a method named 'greetUser' which takes a String input 'name' and it returns a greeting message. Now you need to call this method in another method. Fill the blanks in code to invoke this method properly and print the greeting message for a user.
Method "main"
Invoking a greeting method within another method
Report a typo
Fill in the gaps with the relevant elements
class Main {
public (String[] args) {
String greeting = greetUser("John Doe");
System.out.println(greeting);
}
public static String greetUser(String name) {
return "Hello, " + name + "!";
}
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.