Java for Humans {Input & Output (I/O)}

Lincoln W Daniel
ModernNerd Code
Published in
6 min readJan 17, 2016

--

View Table of Contents | Download Supporting Code | Subscribe to ModernNerd Youtube Channel for Coding Videos | By Lincoln W Daniel

Remember, from the Variables chapter, that we program to capture and manipulate information, or data, to create new data for users to consume. Software programs would not be interesting without being able to capture information, accept input from the user and produce new information — create output for the user to consume.

As a kid, you likely played games that asked for your name and age and used that information to tailor your experience to you. To tailor the gaming experience to you, games usually refer to you by your name and use your age to determine which parts of the game would be most appropriate to show you. In some cases, games may not let you play if you provide an age that is too young. This is all an example of gathering user input and using it to create output for the user. In this chapter, we will learn how Java allows us to easily gather input and produce output in our programs.

Scanning User Input from Keyboard

From the very beginning of the book to now, we’ve been using Java’s Scanner class to capture input from the user. The Scanner class allows you to read input available from an input stream. An input stream simply holds data coming in to your program while an out stream holds data going out of your program. In previous chapters, our input stream has been System.in, which streams in…

--

--

Lincoln W Daniel
ModernNerd Code

Chief Bull @ BullAcademy.org ® Elevating writers @ ManyStories.com. Author @JavaForHumans Ex: Editor in Chief MarkGrowth (acq.), Engineer @Medium @GoPuff