Java Examples
Java ExamplesPrograms with output

Java Program to Get Input from User


Example:
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

Share this page on:

Was this page helpful ?

Let us know how we did!

Subscribe Email Updates

to get latest update