class ArrayInitialization { public static void print(String s, String[] arr){ System.out.println(s); if (arr == null) System.out.println("Empty array"); else for (int index=0;index < arr.length; index++) System.out.println(arr[index]); } public static void main(String[] args){ String[] names = null; String[] cities = {"Roma", "Paris", "London", "Lønholt"}; print("The names reference refers to: ", names); print("The cities reference refers to: ", cities); names = new String[3]; names[0] = "Hans"; names[1] = "Sidhartha"; names[2] = "Krzysztof"; print("The names reference refers to: ", names); // State shown in slide 1 names = new String[]{"Bill","Reagan","Bush Jr"}; print("The names reference refers to: ", names); String[][] twoDim = { {"monkey","donkey"}, {"cow", "giraffe"}}; print("The first dimension refers to: ", twoDim[0]); print("The second dimension refers to: ", twoDim[1]); // State shown in slide 2 twoDim[0] = names; twoDim[1] = cities; print("The first dimension refers to: ", twoDim[0]); print("The second dimension refers to: ", twoDim[1]); // State shown in slide 3 } }