Example I/O Program

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   hear noise   go to next page

Answer:

Have you already used System.out?

Yes, System.out.println( "Some string" ) sends characters to the output stream.

Example I/O Program

Here is a picture of a Java program doing character input and output. In this picture, the white box represents the entire program. The program has imported Scanner for use with input, and has imported System.out for use with output.

echo picture

The nextLine() method of Scanner reads a line of character data from the keyboard. The characters go into a String object. An assignment statment puts a reference to the object in the reference variable inData. To output the characters to the monitor, the program uses the println() method of System.out.

QUESTION 6:

Do you suppose that a Scanner object has more methods than the one method in this picture?