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().
-
48:41
Turning Point Tonight
3 hours ago $1.28 earnedJobob LIVE at AmFest 2025!
8.9K -
4:13:55
Barry Cunningham
4 hours agoLIVE BREAKING NEWS: President Trump Makes Another Address To The Nation! And More News!
12.3K18 -
1:43:53
The Quartering
5 hours agoTucker Vs Ben Shapiro At AMFEST, Epstein Files Release Today & Brown University Shooter Caught!
48.7K28 -
34:43
DeVory Darkins
5 hours agoBREAKING: Jury hands Democrat Judge a GUILTY Verdict after she helped illegal aliens escape
39.1K60 -
DVR
Badlands Media
12 hours agoMAHA News [12.19] Vax Schedule, CBD/Cannabis, HHS on Trans Surgeries, Red Light Therapy
14.5K1 -
11:20
Silver Dragons
2 hours agoCOMEX ALERT - Bullion Banks Flip LONG Silver FIRST TIME EVER?
6.59K3 -
37:49
theyoungrightusa
16 hours ago $4.71 earnedThe Young Right X AmFest
30.1K2 -
2:02:50
The Culture War with Tim Pool
6 hours agoThe FALL of Candace Owens | The Culture War with Tim Pool
247K401 -
1:14:53
Sean Unpaved
4 hours agoThe College Football Playoff Begins Today With Alabama vs. Oklahoma | UNPAVED
32.3K1 -
1:36:33
Misfits Mania
2 days ago $18.34 earnedMISFITS MANIA: Weigh-In & Award Ceremony
73.5K12