Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 608 Bytes

File metadata and controls

32 lines (24 loc) · 608 Bytes

Global Fields

Global fields, accordingly, were always a lie.

int number = 0;

void main() {
    IO.println(number);
    number++;
    IO.println(number);
}

They are just normal fields in the anonymous main class.

class Main {
    int number = 0;

    void main() {
        IO.println(number);
        number++;
        IO.println(number);
    }
}

This means that once you move to programs in multiple files they are no longer global to your program - just the code in the main class.1

Footnotes

  1. Huge bummer, but we will learn how to make actually global things later.