15MultiDimensionalArraysLarge

15MultiDimensionalArraysLarge - Lecture Set #15:...

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

View Full Document Right Arrow Icon
1 CMSC 131 Spring 2008 Jan Plane (adapted from Bonnie Dorr) Lecture Set #15: Two-Dimensional Arrays 1. 2-dimensional arrays 1. Ragged Arrays 2. Rectangular Arrays CMSC 131 Spring 2008 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 CMSC 131 Spring 2008 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];
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.

Page1 / 5

15MultiDimensionalArraysLarge - Lecture Set #15:...

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