Java Arena
Step 2 of 5

Several lines, in order

A program's instructions are called statements. Inside main they run from top to bottom, one after another, and each System.out.println prints one line. Statements like these end with a semicolon ;, much like a sentence ends with a full stop. (Later modules show statements that hold other statements in braces instead, such as if and loops.)

public class Main {
    public static void main(String[] args) {
        System.out.println("3");
        System.out.println("2");
        System.out.println("1");
        System.out.println("Liftoff!");
    }
}
Output
3
2
1
Liftoff!

Swap two of the lines and the countdown is in the wrong order: the computer does exactly what the statements say, in the order they are written.

The output has to match exactly

The checks on this site compare what your program prints with the expected output, character by character. Liftoff! and liftoff! are different, and so are Hello, world and Hello,world. The only things ignored are spaces at the very end of a line and empty lines at the very end of the output. Real programs are held to the same standard: another program reading your output won't guess what you meant.

Less typing

System.out.println is long to type, especially on a phone. On a touch screen, the row of keys under the editor has a sout key that types System.out.println(); for you, with the cursor inside the parentheses. Many Java editors have the same shortcut: type sout and press Tab.

Your task

Challenge 1 of 3

The program prints the first line of a short rhyme. Add the two missing lines so it prints exactly:

Semicolons end the line,
braces keep the blocks in line,
println makes the output shine.

Challenge 2

The morning routine got shuffled. Put the four statements in the right order so the program prints:

Wake up
Brush teeth
Eat breakfast
Start coding

Challenge 3

Print this label exactly, spaces included, with exactly four System.out.println statements, one per line:

+-----------------+
|  JAVA ARENA     |
|  Part 1: Basics |
+-----------------+