1 package test; 2 3 public class Test10 { 4 5 static class Base { 6 private int ba; 7 private boolean[] booleanArray = new boolean[] {true, false}; 8 private byte[] byteArray = new byte[] {-1, 1}; 9 private short[] shortArray = new short[] {-1000, 1000}; 10 private int[] intArray = new int[] {-1000000, 1000000}; 11 private long[] longArray = new long[] {-10000000l, 10000000l}; 12 private float[] floatArray = new float[] {-1, 1}; 13 private double[] doubleArray = new double[] {-1, 1}; 14 private int[] emptyArray = new int[] {}; 15 private int[] nullArray; 16 private int[][] int2dArray = new int[][] {new int[] {1,1}, new int[]{2,2}, null, new int[0]}; 17 private String [] stringArray = new String [] {"a", "b", null, "c"}; 18 private Object [] objectArray = new Object [] {new Object [2], new int[] {1,2,3}, null}; 19 } 20 21 static class A extends Base { 22 Object o; 23 String name; 24 25 boolean b; 26 short s; 27 char c; 28 int i; 29 long l; 30 float f; 31 double d; 32 33 A(Object obj, String name) { 34 o = obj; 35 this.name = name; 36 } 37 } 38 39 public static void test(Object o) { 40 System.out.println(o); 41 } 42 43 public static void main(String args[]) { 44 A a1 = new A(null, "a1"); 45 A a2 = new A(a1, "a2"); 46 A a3 = new A(a2, "a3"); 47 a1.o = a3; 48 49 A a4 = new A(null, "a4"); 50 a4.o = a4; 51 52 for (int i = 0; i < 1000; i++) { 53 test(a1); 54 test(a2); 55 test(a3); 56 test(a4); 57 } 58 } 59 } 60 | Popular Tags |