Respuesta :
Answer:
// program in java.
// package
import java.util.*;
// class definition
class Main
{
// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// object to read input
Scanner scr=new Scanner(System.in);
// ask to enter the name
System.out.print("Enter a name:");
// read name
String name=scr.nextLine();
// print the hello message
System.out.println("Hello "+name);
}catch(Exception ex){
return;}
}
}
Explanation:
Create a Scanner object to read name from user.Read name from user and assign it to variable "y_name".Then print the message Hello followed by the name.
Output:
Enter your name:Krish
Hello Krish