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
GritsGG
4 hours agoWorld Record Win Streak Attempt! #1 Most Wins 3880+!
43 watching -
LIVE
The Rabble Wrangler
15 hours agoBattlefield with The Best in the West
72 watching -
13:56
Cash Jordan
2 hours ago"OPEN BORDERS" Mob BATTERS Portland Jail… 'COMBAT' Marines DEFY Judge, BREAK BONES
887 -
16:44
Russell Brand
3 hours agoAmerica’s Hidden Royalty
14.9K22 -
LIVE
LumpyPotatoX2
3 hours agoLightyear Frontier: Gameplay Showcase - Sponsored Stream
45 watching -
LIVE
ReAnimateHer
7 hours ago $0.13 earnedSurviving the Undead in Cold War Zombies
20 watching -
1:44:25
Redacted News
2 hours agoElection Day Disaster for Trump? Europe preps for WAR against Russia, Israel's PR failure | Redacted
71.5K72 -
LIVE
Wayne Allyn Root | WAR Zone
7 hours agoWatch LIVE: The War Zone Podcast with Wayne Allyn Root
71 watching -
33:39
LibertyRoundTable
4 hours agoWarhawk Down: Dick Cheney’s Legacy & the Rise of Citizen Journalism | LRT Radio 11/4/25”
12 -
2:05:29
The Quartering
5 hours agoEscape From New York, Harvard Bombers Caught, Trump DEFIES Court On SNAP, Bomb Threat On Plane!
153K88