import java.util.Arrays; public final class ArrayLength { void testForSimple2(int[] arr, int[][] arr2) { boolean b = arr2[0].length == arr.length; for(int i=0; ii == arr.length) { System.out.println("impossible"); } } } void testForSimple(int[] arr) { for(int i=0; ii == arr.length) { System.out.println("impossible"); } } } void testEquality(int[] x) { int len = x.length; for(int i=0; i<100; i++) { if (i == len) { x[i] = 10; } } } int[] testFor(int length) { int[] x = new int[length]; for(int i=0; i<=length; i++) { // TODO: warn x[i] = 1; } return x; } public static void testArray2(Object[] x, Object[] y, int a) { if(x[a] == null && a == x.length) { System.out.println("Impossible"); } y[0] = 1; if(y.length > 0) { System.out.println("Always"); } } public static void testArray(int[] x, int a) { if(Math.random() > 0.5) { x[-1] = -2; } if(Math.random() > 0.5) { x[x.length] = -1; } x[a] = 6; if(a < 0) { System.out.println("never"); } } public static void testArrayMethods(int[] x) { Arrays.fill(x, 0, 10, -1); if(x.length < 10) { System.out.println("Impossible"); } Arrays.fill(x, -1); Arrays.fill(x, -1, -1, -1); } static final String[] ARR1 = {}; static final String[] ARR2 = new String[10]; static final String[] ARR3 = new String[] {"foo", "bar", "baz"}; void testFieldInitializers() { if(ARR1.length == 0) System.out.println("yes"); if(ARR2.length == 10) System.out.println("yes"); if(ARR3.length == 3) System.out.println("yes"); } }