Scanner class is used to read input from console. Following code segments takes an integer value from the user through console.

Java Code:
Scanner inputScanner = new Scanner(System.in);
int n = inputScanner.nextInt();