1.1 Example Programs

Most of the example programs given in the text are ready to be executed by a Java system and are similar in form to:


class Test {
	public static void main(String[] args) {
		for (int i = 0; i < args.length; i++)
			System.out.print(i == 0 ? args[i] : " " + args[i]);
		System.out.println();
	}
}

On a Sun workstation, this class, stored in the file Test.java, can be compiled and executed by giving the commands:


javac Test.java
java Test Hello, world.

producing the output:

Hello, world.