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().
-
3:12:59
VapinGamers
3 hours ago $0.01 earnedGrim Trials - Game Review/Playthru - Rougelight Dungeon Crawler - !rumbot !music
15.1K -
2:47:55
Mally_Mouse
10 hours ago🎮 Let's Play!! -- Jak 2 pt. 16
30.9K2 -
52:23
MattMorseTV
5 hours ago $0.63 earned🔴The Cartels are SCREWED.🔴
98.7K124 -
1:32:46
Badlands Media
19 hours agoAltered State S3 Ep. 44
41.4K1 -
21:09
Bearing
16 hours agoAustralian “Racist” Protest EXPLODES 💥 Glowies, Brawls & Media Spin 📣
22.1K31 -
2:53:23
Tundra Tactical
3 hours ago $0.01 earnedTwo Vets, One Ouija Board, Zero Good Decisions
19.6K1 -
3:49:59
Barry Cunningham
9 hours agoPAM BONDI & KRISTI NOEM HOST A PRESS CONFERENCE AND JOHN RICH JOINS THE SHOW!
42.3K35 -
9:26:16
GrimmHollywood
13 hours ago🔴LIVE • GRIMM HOLLYWOOD • RETRO PS2 GAMES • GRIMMDY GAMES • BRRRAP PACK x FINALS RANKED GRIND
19.7K -
LIVE
Cripiechuccles
10 hours ago😁18+💚💙WEEDIE WED WITH CRIPIE💚RUMLUV💙👌SMOKING, GAMING & WATCHING FLICKS!:😁
58 watching -
1:01:50
BonginoReport
7 hours agoSeason 2 Of The Epstein Show Just Dropped - Nightly Scroll w/ Hayley Caronia (Ep.126) - 09/03/2025
102K37