Lesson 5Collecting and Parsing Input from the User

Often, when we are dealing with input devices such as a keyboard or reading data from text files, the incoming data will be in string format. The string data often must be converted to other data types such as integers or decimals before we can use those values in our objects. The process of converting a string type to another type is commonly referred to as parsing.

In the first part of this course, we will be doing a lot of our work using the console window as the user interface, so we will use the console for now. Later, we can use the same techniques when we collect data from other sources, such as web forms or data sources.

CONSOLE INPUT AND OUTPUT

In many programs, we need to be able to accept input from a user as well as define output that the user will see. We've already seen the output side of things: the “Hello, World!” application we started with is an example of this. Now we need to look at how we can get input from the user using the console.

The ability to get input from the user allows us to write ...

Get Job Ready Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.