1 package test3; 2 3 class TransNewClassOld { 4 int k = 1; TransNewClassOld()5 TransNewClassOld() {} TransNewClassOld(int i)6 TransNewClassOld(int i) { k = i; } TransNewClassOld(TransNewClassOld obj)7 TransNewClassOld(TransNewClassOld obj) { k = obj.k; } 8 } 9 10 class TransNewClassNew extends TransNewClassOld { TransNewClassNew()11 TransNewClassNew() { k = 10; } TransNewClassNew(int i)12 TransNewClassNew(int i) { k = i * 10; } TransNewClassNew(TransNewClassOld obj)13 TransNewClassNew(TransNewClassOld obj) { k = obj.k * 2; } 14 } 15 16 class TransNewClassNot extends TransNewClassOld { TransNewClassNot()17 TransNewClassNot() { k = 100; } 18 } 19 20 public class TransNewClass { 21 public static class TransNewClass2 { test()22 public int test() { 23 TransNewClassOld obj = new TransNewClassOld(); 24 TransNewClassOld obj2 = new TransNewClassOld(); 25 TransNewClassOld obj3 = new TransNewClassOld(3); 26 return obj.k + obj2.k + obj3.k; 27 } 28 } 29 test()30 public int test() { 31 TransNewClassOld obj = new TransNewClassOld(); 32 TransNewClassOld obj2 = new TransNewClassOld(4); 33 TransNewClassOld obj3 = new TransNewClassNot(); 34 TransNewClassOld obj4 = new TransNewClassOld(new TransNewClassOld()); 35 return obj.k + obj2.k + obj3.k + obj4.k; 36 } 37 } 38