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().
-
DVR
Flyover Conservatives
21 hours agoHow to Win 2026 Before It Starts — Clay Clark’s Goal-Setting Blueprint | FOC Show
10.9K1 -
12:52
The Kevin Trudeau Show Limitless
2 days agoBeyond Good And Bad: The Hidden Reality Code
40.2K20 -
1:03:11
BonginoReport
6 hours agoBrown U Security Failures EXPOSED - Nightly Scroll w/ Hayley Caronia (Ep.201)
127K38 -
51:09
Patriots With Grit
2 hours agoWill A.I. Replace Doctors? | Dr. Stella Immanuel MD
9.06K3 -
4:10:32
Nerdrotic
7 hours ago $0.16 earnedHollywood's DOOMSDAY! WB FIRESALE! - Friday Night Tights 385 w Zachary Levi
71K15 -
12:25:53
LFA TV
19 hours agoLIVE & BREAKING NEWS! | FRIDAY 12/19/25
194K27 -
1:08:59
Edge of Wonder
5 hours agoNASA’s Intergalactic Spacecraft, Real Dwarves Spotted & Research Roundup
21.1K4 -
1:21:27
Kim Iversen
7 hours agoPutin Says Russia is Ready for WAR With Europe
41.6K89 -
1:24:41
The Daily Signal
5 hours ago $0.21 earned🚨BOMBSHELL: 315,000+ Illegal Ballots in Georgia, Terrorists Released, Rubio Slashes Foreign Aid
32.2K9 -
1:53:45
The Mike Schwartz Show
8 hours agoTHE MIKE SCHWARTZ SHOW Evening Edition 12-19-2025
22.8K4