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().
-
2:09:24
Inverted World Live
7 hours agoRats Have Learned to Hunt Bats | Ep. 135
31.2K15 -
2:48:01
TimcastIRL
8 hours agoLIVE Election Coverage: Polling Stations SWATTED, Bomb Threats Called In | Timcast IRL
254K177 -
3:30:07
Barry Cunningham
8 hours agoBREAKING NEWS: COUNTDOWN TO COMMUNISM! ELECTION RESULTS SHOW!
59.5K47 -
2:11:28
DeVory Darkins
8 hours agoLIVE NOW: 2025 Election results and Exit Polls AMA
70K46 -
2:34:04
DLDAfterDark
6 hours ago $0.08 earnedJust Another Tuesday - In Virginia - The Governor's Race & Glock Talk
29.3K7 -
3:21:38
The Charlie Kirk Show
9 hours agoJUDGMENT DAY 2025: The Election Results Stream
200K82 -
3:51:07
MattMorseTV
10 hours ago $0.82 earned🔴Election Day LIVE COVERAGE.🔴
99.2K49 -
1:16:51
Flyover Conservatives
1 day agoSHOCKING DATA REVEALS: Young Voters Are Done With the Old GOP - Mark Mitchell, Rasmussen Reports | FOC Show
42.8K17 -
1:15:28
Sarah Westall
10 hours agoGrooming is Protected and Encouraged by the System – Michelle Peterson and Mike Adamovich
35.9K10 -
4:00:13
Akademiks
7 hours agoKendrick tries to Flip the Bots on DRAKE? WHo Beats Jay z in a verzuz. Blueface finally free!
40K11