Skip to content

Notes

Estimated time to read: 1 minute

Class designation

public class TestClass {

    // section 1:
    private String testName;

    // section 2:
    public TestClass( String name, int i ) {
        this.testName = name;
    }

    // section 3:
    public void countToThree() {
        for (int m = 1; m <= 3; m++) {
            System.out.println( "Count is: " + m );
        }
    }
}
A class method is designated using the static keyword.

The second section is defining a constructor, which is used to create an instance of the class.