Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 458 Bytes

File metadata and controls

24 lines (18 loc) · 458 Bytes

main

The main method works the same as any other method. Java just treats it special by choosing to call it in order to start your programs.

void main() {
    System.out.println("Java will start here");
}

This means you can do anything in your main method you can do in any other method, including returning early.

void main() {
    int x = 5;

    if (x == 5) {
        return;
    }

    System.out.println("WONT RUN");
}