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().
-
LIVE
SportsPicks
5 hours agoCrick's Corner: Episode 80
45 watching -
2:06:51
The Charlie Kirk Show
3 hours agoVice President JD Vance Remembers Charlie Kirk | Miller, Tucker, RFK Jr., Wiles, Leavitt | 9.15.25
1.39M1.21K -
LIVE
Major League Fishing
5 days agoLIVE! - Fishing Clash Team Series: Heritage Cup - Day 2
324 watching -
1:08:54
Simply Bitcoin
4 hours ago $0.82 earnedNEW REPORT SUGGESTS THE BITCOIN SUPPLY SHOCK IS ACCELERATING?! | EP 1332
21.2K1 -
10:31
Dr. Eric Berg
4 hours ago13 Foods You Should Never Buy Organic
79.2K20 -
15:10
SB Mowing
1 month agoShe had TEARS OF JOY on her face - An update on Beth
60.6K35 -
LIVE
Lofi Girl
3 years agolofi hip hop radio 📚 - beats to relax/study to
351 watching -
2:15:26
Nikko Ortiz
4 hours agoLIVE - Farm Animals Attack!
217K7 -
9:30
Sugar Spun Run
7 hours ago $1.66 earnedBlack and White Cookies
119K2 -
2:45
SLS - Street League Skateboarding
4 days agoManny Santiago's 'THIS IS 40' Part
70.5K2