Input and Output

Java provides a Scanner class to facilitate data input/output. In this section, you will learn about the Scanner class that is used to get input from the user. Java also defines various methods from the Scanner class can convert user input into appropriate data types before conducting any operation on the data.

1. Input and Output

This chapter discusses input and output. Most programs input data, process it, and then output the results. This chapter discusses ways to input data from the keyboard and output results to the monitor. Later chapters will discuss input and output from disk files and other media.

Chapter Topics:

      • Input and Output Streams
      • The standard I/O streams
      • Scanner class
      • Converting character data to type int

Question 1:

When a computer program does an input operation, in which direction does the data flow?

  • From an outside device into the program?
  • From the program out to some device?

Source: Bradley Kjell,
Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 License.