Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class ThisUsage {
  2.     int id;
  3.  
  4.     ThisUsage(int i) {
  5.         this.id = i;// access and initialize field from the constructor
  6.     }
  7.  
  8.     ThisUsage() {
  9.         this(1);// invoke the constructor with one parameter.
  10.     }
  11.  
  12.     public static void main(String[] args) {
  13.         ThisUsage tu = new ThisUsage();
  14.         ThisUsage tu2 = new ThisUsage(2);
  15.         System.out.println("If no id provided, the default id is-->" + tu.id);
  16.         System.out.println("otherwise, print the user-defined id -->" + tu2.id);
  17.     }
  18. }
  19.  
  20.