Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 477 Bytes

File metadata and controls

27 lines (24 loc) · 477 Bytes

Static Methods

If you want to be able to call a method from anywhere in your program you can use a static method.

class MyMath {
    static int add(int a, int b) {
        return a + b;
    }
}
~class MyMath {
~    static int add(int a, int b) {
~        return a + b;
~    }
~}
class Main {
    void main() {
        int result = MyMath.add(1, 2);
        IO.println(result);
    }
}