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
StoneMountain64
4 hours agoBattlefield REDSEC leveling guns for attachments
215 watching -
LIVE
Wayne Allyn Root | WAR Zone
7 hours agoWatch LIVE: The War Zone Podcast with Wayne Allyn Root
125 watching -
33:39
LibertyRoundTable
3 hours agoWarhawk Down: Dick Cheney’s Legacy & the Rise of Citizen Journalism | LRT Radio 11/4/25”
12 -
2:05:29
The Quartering
4 hours agoEscape From New York, Harvard Bombers Caught, Trump DEFIES Court On SNAP, Bomb Threat On Plane!
153K88 -
16:30
Clintonjaws
19 hours ago $11.55 earned'The View's' Producer Stops Show & Forces Whoopie To Correct Lie
32.5K19 -
10:51
Scammer Payback
3 hours agoScammer's Meltdown after He's Been Hacked
3.72K3 -
LIVE
LFA TV
20 hours agoLIVE & BREAKING NEWS! | TUESDAY 11/4/25
1,232 watching -
LIVE
freecastle
6 hours agoTAKE UP YOUR CROSS- INTEGRITY of the upright GUIDES them, CROOKEDNESS of the treacherous DESTROYS!
116 watching -
2:04:16
Pop Culture Crisis
3 hours agoCoca-Cola's WAR ON CHRISTMAS, Movie Press Tour CRINGE, Gen Z HATES Gen Z | Ep, 949
28.5K4 -
1:10:24
Steve-O's Wild Ride! Podcast
5 days ago $1.53 earnedMatt McCusker Makes Steve-O Nervous | Wild Ride #272
24.9K2