Constructors

builders

Default Constructor

public class TestClass {
    private String test;

    public TestClass() {
    }
}

The "default" for constructors is that they do not have any arguments.The visibility of the default constructor is the same as the visibility of the class. Thus a class defined package- privately has a package-private default constructor

Normal Constructor

public class TestClass {
    private String test;
    public TestClass() {
    }
    public TestClass(String arg) {
    }
}

You can have more than one constructor

Last updated

Was this helpful?