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().
-
15:31
Breaking Points
1 day agoIs Trump Planning VENEZUELA Regime Change?
33.1K24 -
2:06:05
"What Is Money?" Show
2 days agoTrump Family Bitcoin Bet Will Trigger Nation-State FOMO w/ Matt Prusak (CEO American Bitcoin)
13.4K -
1:04:36
Dialogue works
3 days ago $4.50 earnedMohammad Marandi: Iran Just Gave Israel a FINAL Warning…
23.4K6 -
9:20
daniellesmithab
1 day ago3 Bad Laws
23.3K8 -
9:22
MattMorseTV
19 hours ago $11.63 earnedINDIA just made a BIG MISTAKE.
65.1K60 -
12:11
Nikko Ortiz
18 hours agoCrashout 6 Rumble
17.5K3 -
22:35
GritsGG
18 hours agoThe KILO is BACK! The Best AR on Warzone FRIES!
25.7K1 -
2:16:36
Side Scrollers Podcast
21 hours agoStreamer KICKED OUT of Renaissance Fair for Misgendering + Spiderman MELTDOWN | Side Scrollers Live
47.4K8 -
12:29
The Pascal Show
1 day ago $2.53 earnedLOCKED IN A DUNGEON?! Parents Arrested After 5 Children Found In 'Dungeon' At Home
18.7K3 -
LIVE
Lofi Girl
2 years agoSynthwave Radio 🌌 - beats to chill/game to
321 watching