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
DLDAfterDark
2 hours agoIs The "SnapPocalypse" A Real Concern? Are You Prepared For SHTF? What Are Some Considerations?
69 watching -
19:58
TampaAerialMedia
13 hours ago $0.09 earnedKEY LARGO - Florida Keys Part 1 - Snorkeling, Restaurants,
3.32K6 -
1:23
Memology 101
2 days ago $0.55 earnedFar-left ghoul wants conservatives DEAD, warns Dems to get on board or THEY ARE NEXT
6.62K34 -
3:27:27
SavageJayGatsby
4 hours ago🔥🌶️ Spicy Saturday – BITE Edition! 🌶️🔥
41.3K -
26:09
Exploring With Nug
13 hours ago $8.95 earned13 Cold Cases in New Orleans What We Discovered Beneath the Surface!
41.2K13 -
27:39
MYLUNCHBREAK CHANNEL PAGE
8 hours agoDestroying Time.
124K25 -
DVR
Mally_Mouse
4 hours ago🌶️ 🥵Spicy BITE Saturday!! 🥵🌶️- Let's Play: Minecraft Christmas Adventure!!
126K4 -
2:14:31
Side Scrollers Podcast
9 hours agoSide Scrollers INVITE ONLY - Live From Dreamhack
154K12 -
1:18:23
Simply Bitcoin
2 days ago $13.78 earnedThe Bitcoin Crucible w/ Alex Stanczyk and Lawrence Lepard
35.9K5 -
1:25:03
Jeff Ahern
9 hours ago $21.77 earnedThe Saturday Show with Jeff Ahern
98.7K13