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().
-
1:21:27
Kim Iversen
5 hours agoPutin Says Russia is Ready for WAR With Europe
21.2K69 -
The Daily Signal
3 hours ago🚨BOMBSHELL: 315,000+ Illegal Ballots in Georgia, Terrorists Released, Rubio Slashes Foreign Aid
4.22K6 -
LIVE
The Mike Schwartz Show
5 hours agoTHE MIKE SCHWARTZ SHOW Evening Edition 12-19-2025
603 watching -
37:38
The Nunn Report - w/ Dan Nunn
4 hours ago[Ep 814] LIVE From AmFest 2025 with Kaitlin Bennett
29.3K10 -
27:40
Stephen Gardner
7 hours agoYES! Rubio & Hegseth Get Trump's 2 National Security Orders
39.7K40 -
1:48:18
vivafrei
6 hours agoBrown Shooter Identified - Suspect or Patsy? Judge CONVICTED for Aiding Illegals! Bongino Resigns!
58K55 -
48:41
Turning Point Tonight
7 hours ago $2.66 earnedJobob LIVE at AmFest 2025!
39.6K -
4:13:55
Barry Cunningham
8 hours agoLIVE BREAKING NEWS: President Trump Makes Another Address To The Nation! And More News!
41.4K32 -
1:43:53
The Quartering
8 hours agoTucker Vs Ben Shapiro At AMFEST, Epstein Files Release Today & Brown University Shooter Caught!
75.2K54 -
34:43
DeVory Darkins
8 hours agoBREAKING: Jury hands Democrat Judge a GUILTY Verdict after she helped illegal aliens escape
56K83