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:00:41
Omar Elattar
5 hours ago“I Was Homeless On NYC Streets!” - Tequila CEO Shares Her Multi-Million Dollar Story
42.7K3 -
DVR
The Pascal Show
2 hours ago $0.16 earnedRIOTS NATIONWIDE?! Anti-ICE Protests Throughout The Country! LA, NYC & More Absolute Chaos!
17.7K1 -
27:54
Stephen Gardner
7 hours ago🔥RFK Jr. makes SHOCKING ANNOUNCEMENT!
54.8K31 -
1:31:42
Badlands Media
1 day agoAltered State S3 Ep. 32: Project Cyberspace, Deep State Games & the War for Perception
62.5K1 -
LIVE
svgames
3 hours ago🟢LIVE - GAMING
64 watching -
11:02
ARFCOM News
9 hours ago $0.66 earnedATF Goes After Pin & Weld Barrels | The FBI Caught Some Actual Nazis | Cop Shoots Tiny Puppy
15.8K8 -
LIVE
KingB33Gaming
9 hours agoThe Wind Waker | Nintendo Switch 2 Gamecube Virtual Console
83 watching -
44:19
CarlCrusher
4 hours agoBombshell UFO News Immaculate Constellation REAL & Dr Hal Puthoff Appears on Joe Rogan
24.6K4 -
LIVE
Rhino6888
6 hours agoGTA STORY MODE, COME CHAT, DROP A FOLLOW!
68 watching -
1:06:31
The Daily Signal
4 hours ago $0.84 earned🚨 LIVE: Possible Strike on Iran IMMINENT, Nationwide Riots Intensify
57.1K11