1.2. Example Programs

Most of the example programs given in the text are ready to be executed 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 machine with the Oracle JDK installed, this class, stored in the file Test.java, can be compiled and executed by giving the commands:

javac Test.javajava Test Hello, world.

producing the output:

Hello, world.

Get The Java® Language Specification, Java SE 7 Edition, Fourth 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.