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:45:51
Game On!
1 day ago $11.12 earnedWise Guys Reveal NFL Week 2 BEST BETS Now
79.2K8 -
26:57
Robbi On The Record
2 days agoMouth Breathing Is Why You’re Exhausted | with Dr. Melanie Silvestrini
49.9K6 -
LIVE
Total Horse Channel
8 hours ago2025 Reno Snaffle Bit Futurity | Sunday Finals
99 watching -
40:44
SouthernbelleReacts
7 days ago $4.04 earned“Event Horizon (1997) Reaction | Hellraiser in Space with Sam Neill & Laurence Fishburne”
46.3K4 -
10:49
Artur Stone Garage
3 days ago $2.75 earnedI Spent $2000 on My Turbo Honda Civic Build (Before & After)
44.4K12 -
0:44
Danny Rayes
21 hours ago $4.51 earnedDid Someone Know It Was Going To Happen?
43K11 -
15:03
World2Briggs
1 day ago $3.63 earnedShocking Home Prices in Florida's Cheapest Towns!
36.1K8 -
58:02
ChopstickTravel
4 days ago $1.58 earnedBillionaire Food in Dubai 🇦🇪 Super Luxury MICHELIN +WAGYU + CAVIAR in UAE!
25.9K1 -
21:20
Advanced Level Diagnostics
12 days ago $1.22 earned2020 Toyota Sienna - Crank No Start! Never Seen This Before!
27K2 -
49:04
The Why Files
6 days agoMajestic 12 | Secret Documents Expose UFO Cover-Up Vol. 1
62.2K72