10MultiDimensionalArraysSmall

10MultiDimensionalArraysSmall - 11/1/2009 Lecture Set #10:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
11/1/2009 1 CMSC 131 Fal 2009 Jan Plane (adapted from Bonnie Dorr) Lecture Set #10: Two-Dimensional Arrays 1. 2-dimensional arrays 1. Ragged Arrays 2. Rectangular Arrays CMSC 131 Fal 2009 Jan Plane (adapted by Bonnie Dorr) 1 Recall Arrays c Arrays: sequences of elements from the same base type int[] a; // array of ints Date[] d; // array of references to Dates c Base type may be: c Primitive (i.e. int ) c Reference (i.e. Date , other objects) c Arrays are also objects. c Notice the similarities: c Arrays created using new c Array elements stored on heap c Array variables store references to space on the heap CMSC 131 Fal 2009 Jan Plane (adapted by Bonnie Dorr) 2 Allocation of Space c Syntax for allocating space for the 1 st level array: char[][] a; // Array of char arrays a = new char[3][]; // Create array of 3 arrays c Syntax for allocating space for the 2 nd level of arrays: a[0] = new char[4]; // Create array of 4 char a[1] = new char[6]; // Create array of 6 char a[2] = new char[3]; // Create array of 3 char
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
11/1/2009 2 CMSC 131 Fal 2009 Jan Plane (adapted by Bonnie Dorr) 3 Example
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/04/2011 for the course CMSC 131 taught by Professor Plane during the Fall '08 term at Maryland.

Page1 / 3

10MultiDimensionalArraysSmall - 11/1/2009 Lecture Set #10:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online