---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 12 Edition"
java_version: 12
chapter: "Chapter 1. Introduction"
section: "1.2"
heading: "1.2. Example Programs"
parent: "Chapter 1. Introduction"
source: https://docs.oracle.com/javase/specs/jls/se12/html/jls-1.html#jls-1.2
id: "1.2"
url: https://jvm.obfuscated.software/jls/se12/1.2.html
raw: https://jvm.obfuscated.software/jls/se12/1.2.md
---

# 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.java
java Test Hello, world.
```

producing the output:

```
Hello, world.
```
