You are working on a simple Java program that should greet the user if their name is specified as the application's parameter, otherwise it should print 'Hello, world!' to the console. The program should be launched from the command line. Fill the blanks in the code so that it behaves according to the requirements.
Compile and run Java from CLI
Greeting user by name or printing a default message
Report a typo
Fill in the gaps with the relevant elements
Main {
public static void (String[] args){
if(args.length>0){
("Hello, " + args[0] + "!");
}
else {
System.out.println("Hello, world!");
}
}
}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.