1 public class DispatchTest { 2 public int a; 3 public float b; 4 5 public DispatchTest() { 6 this.a = 1; 7 this.b = 2; 8 } 9 10 public DispatchTest(int a) { 11 this.a = a; 12 this.b = 2; 13 } 14 15 public DispatchTest(float b) { 16 this.a = 1; 17 this.b = b; 18 } 19 20 public DispatchTest(int a, float b) { 21 this.a = a; 22 this.b = b; 23 } 24 25 public void set(int a) { 26 this.a = a; 27 } 28 29 public void set(float b) { 30 this.b = b; 31 } 32 33 public int test(DispatchInterface obj) { 34 return obj.test(); 35 } 36 37 public int test(DispatchClass1 obj) { 38 return obj.test(); 39 } 40 41 public int testTest(DispatchInterface obj) { 42 return test(obj); 43 } 44 } 45 46 interface DispatchInterface { 47 public int test(); 48 } 49 50 class DispatchClass1 implements DispatchInterface { 51 public int test() { 52 return 1; 53 } 54 } 55 56 class DispatchClass2 implements DispatchInterface { 57 public int test() { 58 return 2; 59 } 60 }