Previous


1.1 Changes: Textual Program Output

In releases prior to the JDK 1.1, programmers used System.out to display textual output from their programs. In JDK 1.1, System.out should be used only for debugging purposes. Instead of using System.out to create program output, programmers should create a PrintWriter and use it instead.

Here's the HelloWorldApp program re-written to use a PrintWriter to display its output rather than System.out:

import java.io.PrintWriter;

class HelloWorldApp {
    public static void main (String[] args) {
	PrintWriter stdout = new PrintWriter(System.out, true);
        stdout.println("Hello World!");
    }
}
Note: Example programs throughout this tutorial still use System.out to display program output in the manner of programs prior to JDK 1.1.


Previous