LECTURE NOTES NOVEMBER 18 2004 ASSIGNMENTS Read 10.5 11:58 PM CodeLab #11 Mon 11/22 Assignment 4 TWO-DIMENSIONAL ARRAYS Why? - common, effect means for communicating information What? - table organized in columns How? - in Java, 2D array - array elements can contain anything, including another array What? - subarray: an array inside of another array What? - 2D arrays in Java How? - no explicity 2D array structure - instead, use the array structure to make an array of arrays What? - declare a 2D array How? - each element contains an array: [] - to declare an array we did: [] - now the type is another array: [][] [][] ; [][]; What? - create a 2D array How? - create the 1D array - use a loop to allocate a new array in every position What? - create a 2D array shorthand How? = new [][]; What? - accessing the elements of a 2D array How? - need two indexes, one for the rows, one for the columns - conventionally, treat the first set of brackets as the rows What? - initializing a 2D array How? - nested for loops What? - initializing a 2D array shorthand How? - nest the curly brace syntax What? - no limit on the number of dimensions an array can have How? - extend 2D to ND just like we extended 1D to 2D Why? - actually, uncommon in object oriented programming, because we can use classes to better model such complex structures REVIEW EXAM REVIEW ASSIGNMENT 4 INTRODUCE ASSIGNMENT 5