Premium Only Content
How to Print an Integer entered by a user | Java Examples
In this program, you'll learn to print a number entered by the user in Java. The integer is stored in a variable using System.in, and is displayed on the screen using System.out.
In this program, an object of Scanner class, reader is created to take inputs from standard input, which is keyboard.
Then, Enter a number prompt is printed to give the user a visual cue as to what they should do next.
reader.nextInt()then reads all entered integers from the keyboard unless it encounters a new line character \n (Enter). The entered integers are then saved to the integer variable number.
If you enter any character which is not an integer, the compiler will throw an InputMismatchException.
Finally, number is printed onto the standard output (System.out) - computer screen using the function println().
-
LIVE
The Mel K Show
1 hour agoA Republic if You Can Keep It-Americans Must Choose 11-04-25
537 watching -
LIVE
Grant Stinchfield
1 hour agoThe Mind Meltdown: Are COVID Shots Fueling America’s Cognitive Collapse?
140 watching -
1:00:46
VINCE
4 hours agoThe Proof Is In The Emails | Episode 161 - 11/04/25
146K115 -
2:12:22
Benny Johnson
2 hours ago🚨Trump Releases ALL Evidence Against James Comey in Nuclear Legal BOMBSHELL! It's DARK, US in SHOCK
77.7K26 -
2:04:05
Badlands Media
11 hours agoBadlands Daily: November 4, 2025
58.6K8 -
2:59:49
Wendy Bell Radio
7 hours agoBUSTED.
71.6K83 -
1:15:01
The Big Mig™
4 hours agoDing Dong The Wicked Witch Pelosi Is Gone
12.3K6 -
34:57
Daniel Davis Deep Dive
3 hours agoFast Tracking Weapons to Ukraine, Close to $3 Billion /Lt Col Daniel Davis
16.9K7 -
DVR
The State of Freedom
5 hours ago#347 Relentlessly Pursuing Truth, Transparency & Election Integrity w/ Holly Kesler
10.9K -
1:34:34
Graham Allen
4 hours agoThe MAGA “Civil War” Will LOSE The Midterms! Is A Fracture Coming? ALL Eyes On Key Races!
89.7K44