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().
-
1:00:59
Squaring The Circle w/ Randall Carlson
21 hours ago#007 The Real Climate Crisis Noone Is Talking About and Mount Tambora Pt 2
18.7K9 -
13:52
America Uncovered
22 hours agoEveryone is WRONG About Trump's Guilty Verdict
11.6K28 -
13:10
Censored TV
21 hours agoThe Owen Benjamin vs Jim Goad debate was WILD
9.14K14 -
25:27
Degenerate Plays
13 hours agoThe Microtransaction Master - Call Of Duty Modern Warfare Remastered : Part 3
13.7K1 -
21:03
MYLUNCHBREAK CHANNEL PAGE
16 hours agoOld World Minnesota?
18.8K17 -
5:49:05
Akademiks
22 hours agoDrake Next Move - Whats next?? Did Lil Baby Listen to Me? Diddy and Family Preparing for Indictment?
68K37 -
1:56:06
TimcastIRL
1 day agoTrump Raises RECORD $52.8 MILLION In One Day, Bonus Uncensored Show w/Laura Loomer | Timcast IRL
94.1K384 -
23:19
Scammer Payback
4 days agoWe Created the First Ever 𝗔𝗡𝗧𝗜-𝗦𝗖𝗔𝗠 Call Center
214K250 -
1:11:09
LFA TV
23 hours agoTRUMP GUILTY…OF LOVING AMERICA! Ft. Hayley Caronia & Vish Burra | LAST CALL 6.1.24 8PM EST
76.4K40 -
1:02:02
The Kirk Minihane Show
15 hours ago420 Show
53.3K2