Print an Integer given by user
In this example, we are giving a program to Print an Integer given by an user.
To print an Integer given by user:
# To print an Integer given by user
public classimport java.util.Scanner;
class HelloWorld {
public static void main(String args[]) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter a number: ");
int number = reader.nextInt();
System.out.println("You entered: " + number);
}
}
Output:
Enter a number: 73 You entered: 73