Chapter 4. Input and output

Input and output

4.1 Inputting interactively

4.2 User-friendly input–output

4.3 Creating and accessing packages

4.4 Selection with if-else

4.5 File input and output

4.6 Handling exceptions

In this chapter we focus on input and output and introduce two custom-made Java classes that give a simple yet powerful means of interacting with a program. By being able to read in values to a program, we change its state. Two other ways of changing the state are by means of explicit selection (the if-statement) and reacting to exceptions. Using the IO classes both on the screen and with files requires that we know how to create and use packages, which is ...

Get Java Gently, Third Edition 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.