public class ThisUsage {
int id;
ThisUsage(int i) {
this.id = i;// access and initialize field from the constructor
}
ThisUsage() {
this(1);// invoke the constructor with one parameter.
}
public static void main(String[] args) {
ThisUsage tu = new ThisUsage();
ThisUsage tu2 = new ThisUsage(2);
System.out.println("If no id provided, the default id is-->" + tu.id);
System.out.println("otherwise, print the user-defined id -->" + tu2.id);
}
}