import java.util.Scanner;
class Main
{
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
int name;
System.out.print("Enter Name: ");
name = input.nextInt(); //gets the next integer entered from terminal
if (name == 2)
System.out.println("Hello");
System.out.println(name);
}
}
This code should work. To get input from keyboard use input.next(); (this gets string values) or for specific types like ints, use input.nextInt(); to get the next int entered.