Java Program to Get Input from User


-

-

Example:

Copied
import java.util.Scanner;

public class UserInput
{
	public static void main(String args[])
	{
		int num;
		Scanner scan = new Scanner(System.in);
		
		System.out.print("Enter a Number  ");
		num = scan.nextInt();
		
		System.out.print("You entered: " +num);
	}
}

Output:

Enter a Number: 10
You Entered: 10