/** * This code is from the book: * Winder, R and Roberts, G (1998) * Developing Java Software * John Wiley & Sons. * It is copyright (c) 1997 Russel Winder * and Graham Roberts. */ class l1ClThis1{//This private int i = 10; private int j = this.i;//same as private int j=i; private int k; { k = this.j;}//same as private int k = j; public l1ClThis1(){ this(10);//call the other constructor } private l1ClThis1(int i){ this.i = i; } public void f(){ //CANNOT assign to this as the current object //cannot be changed. //this = new Test(); //ILLEGAL: can ONLY call constructors //from a constructor //this(10); } public static void main(String[] args){ l1ClThis1 t = new l1ClThis1(); l1ClThis1 t2 = new l1ClThis1(10); } } /******** sample compilation & run ******** # javac l1ClThis1.java # java l1ClThis1 # ******************************************/