COMPSCI 2S03 Lecture Notes - Lecture 13: Memory Management
Document Summary
Represented as a table (two-dimensional array or matrix because of rows and columns) First indice is row, second indice is column. Memory allocation and how you access the elements. If you"d like to iterate over multidimensional array, you cannot iterate over it directly! Need two loops for two dimensional three for three dimensional etc. Methods (create the two-dimensional array, iterate over elements using two indices if two dimensional the number of indices indicates the dimension) Int arrays are initialized with the default value (zero for int) We use curly brackets {} to declare elements explicitly int[][] weeklydata = {{1}, {1}, {1}} three elements, each element is an array int[3][7] two dimensional array with three elements of 7 element long arrays, fixed-size. Multi-dimensional arrays can be different sizes, but you must specify the length rainfalldata = new double[3][]; rainfalldata[0] = new double[1]; rainfalldata[1] = new double[2]; rainfalldata[2] = new double[3];