|
| 1 | +public class ArrayClone { |
| 2 | + public static void cloneReference() { |
| 3 | + ArrayClone[] a = {new ArrayClone(), new ArrayClone() }; |
| 4 | + ArrayClone[] clone = a.clone(); |
| 5 | + |
| 6 | + assert(a.length == clone.length); |
| 7 | + } |
| 8 | + |
| 9 | + public static void cloneObejct() { |
| 10 | + Object[] a = {new Object(), new Object() }; |
| 11 | + Object[] clone = a.clone(); |
| 12 | + |
| 13 | + assert(a.length == clone.length); |
| 14 | + } |
| 15 | + |
| 16 | + public static void cloneByteArray() { |
| 17 | + byte[] a = {(byte) 1, (byte) 2}; |
| 18 | + byte[] clone = a.clone(); |
| 19 | + |
| 20 | + assert(a.length == clone.length); |
| 21 | + } |
| 22 | + |
| 23 | + public static void cloneShortArray() { |
| 24 | + short[] a = {(short) 1, (short) 2}; |
| 25 | + short[] clone = a.clone(); |
| 26 | + |
| 27 | + assert(a.length == clone.length); |
| 28 | + } |
| 29 | + |
| 30 | + public static void cloneIntArray() { |
| 31 | + int[] a = {1, 2}; |
| 32 | + int[] clone = a.clone(); |
| 33 | + |
| 34 | + assert(a.length == clone.length); |
| 35 | + } |
| 36 | + |
| 37 | + public static void cloneLongArray() { |
| 38 | + long[] a = {1L, 2L }; |
| 39 | + long[] clone = a.clone(); |
| 40 | + |
| 41 | + assert(a.length == clone.length); |
| 42 | + } |
| 43 | + |
| 44 | + public static void cloneFloatArray() { |
| 45 | + float[] a = {1.0f, 2.0f}; |
| 46 | + float[] clone = a.clone(); |
| 47 | + |
| 48 | + assert(a.length == clone.length); |
| 49 | + } |
| 50 | + |
| 51 | + public static void cloneDoubleArray() { |
| 52 | + double[] a = {1.0, 2.0}; |
| 53 | + double[] clone = a.clone(); |
| 54 | + |
| 55 | + assert(a.length == clone.length); |
| 56 | + } |
| 57 | + |
| 58 | + public static void cloneBooleanArray() { |
| 59 | + boolean[] a = {true, false}; |
| 60 | + boolean[] clone = a.clone(); |
| 61 | + |
| 62 | + assert(a.length == clone.length); |
| 63 | + } |
| 64 | + |
| 65 | +} |
0 commit comments