COMPSCI 2S03 Lecture Notes - Lecture 13: Memory Management

40 views2 pages

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];

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents