Java Program to Read Integer Value from the Standard Input

Write a Java program to read integer value from the standard input or console. To do this, we use the util packages Scanner class. First, import the same, and create an instance or object of the Scanner class and pass the System.in parameter.

package RemainingSimplePrograms;

import java.util.Scanner;

public class ReadInteger1 {
	
	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);
		
		System.out.print("Enter Any Integer Value = ");
		
		int num = sc.nextInt();
		sc.close();
		
		System.out.println("Given Integer Value = " + num);

	}
}
Read Integer Value from the Standard Input