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().
-
12:52
ROSE UNPLUGGED
22 hours agoFrom Vision to Legacy: Charlie Kirk
45.8K19 -
1:14:22
Jeff Ahern
6 hours ago $10.58 earnedThe Sunday Show with Jeff Ahern
70.8K28 -
16:37
Professor Nez
6 hours ago🚨Internet MELTS DOWN over JD Vance & Trump BREAKING the Democrats!
53.7K174 -
18:40
itsSeanDaniel
8 hours agoPiers Morgan CALLED OUT and HUMILIATED by Andrew Tate
73K278 -
DVR
Times Now World
2 days agoLIVE: "ON CAM: How the Charlie Kirk Shooter ESCAPED – Shocking New Footage Revealed!"
86.7K16 -
1:45:51
Game On!
1 day ago $11.54 earnedWise Guys Reveal NFL Week 2 BEST BETS Now
100K8 -
26:57
Robbi On The Record
2 days agoMouth Breathing Is Why You’re Exhausted | with Dr. Melanie Silvestrini
73.1K7 -
LIVE
Total Horse Channel
11 hours ago2025 Reno Snaffle Bit Futurity | Sunday Finals
89 watching -
40:44
SouthernbelleReacts
7 days ago $4.43 earned“Event Horizon (1997) Reaction | Hellraiser in Space with Sam Neill & Laurence Fishburne”
56.6K6 -
10:49
Artur Stone Garage
3 days ago $2.88 earnedI Spent $2000 on My Turbo Honda Civic Build (Before & After)
51.3K13