Enter the integer from user using Scanner class

Source Code:

import java.util.Scanner;

public class IntInput {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter an integer: “);
int n = sc.nextInt();
System.out.println(“You entered: ” + n);
}
}

Output: