How to get number from user in java?

To get input from user in java we use Scanner object from Scanner library.

import java.util.Scanner;

public class ScannerNum {
	public static void main (String arg[]){
		Scanner xScanner=new Scanner(System.in);
		int number;
		System.out.print("Please enter a number: ");
		number=xScanner.nextInt();
		System.out.print("The number is "+number);
		xScanner.close();
	}

}