public class ArraysTest{ public static void main(String[] args) { // These define pointers to an int and a String array. // At this point only pointers have been defined; no memory // has been allocated. int[] x; String[] y; // These statements allocate memory for x and y // Unlike in C/C++ x points to the whole array object, not // just the first slot in the array. So one cannot increment // x and refer to the second slot. x = new int[100]; y = new String[10]; int i; for(i = 0; i < 100; i++) { x[i] = i*i; } y[0] = "zero"; for(i = 1; i < 10; i++) { y[i] = y[i-1]+"+one"; } System.out.println(x[10]); System.out.println(y[5]); } }