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
Phyxicx
3 hours agoRocket League with Friends! - 11/22/2024
114 watching -
LIVE
STARM1X16
3 hours agoFriday Night Fortnite
87 watching -
29:51
Afshin Rattansi's Going Underground
19 hours agoJimmy Dore on Ukraine & WW3: Biden Wants a War that Trump CAN’T Stop, ONLY Hope is Putin’s Restraint
56.7K18 -
DVR
Fresh and Fit
5 hours agoExposing WHO Killed JFK w/ Cory Hughes & Tommy Sotomayor
72.6K24 -
LIVE
RanchGirlPlays
5 hours ago🔴 Red Dead Redemption: Let's go help De Santa 🤠
177 watching -
LIVE
Man in America
12 hours agoWHAT?! Trump & the Fed are DISMANTLING the Global Banking Cartel!? w/ Tom Luongo
2,342 watching -
HELMET FIRE
2 hours agoDEADROP IS BACK!
3.11K2 -
LIVE
I_Came_With_Fire_Podcast
7 hours agoLive Fire (No Exercise) with DAN NUNN!!!
241 watching -
1:57:20
Glenn Greenwald
7 hours agoBiden's Escalation Of The War In Ukraine With Scott Horton; Lee Fang On The Junk Food Industry Sabotaging RFK Jr.'s Plans & The Gaetz Situation | SYSTEM UPDATE #371
77K79 -
LIVE
Toitle
2 hours agoLet's Game | TOITLE HEADS, POKE OUT | WE BE GRINDIN
139 watching