18CollectionsLarge

18CollectionsLarge - Lecture Set #18: Collections 1. 1. New...

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 #18: Collections 1. New Looping construct 1. for each loop 2. Collections 1. Stack 2. ArrayList CMSC 131 Spring 2008 Jan Plane (adapted from Bonnie Dorr) 1 Collections in Java c Arrays are collections c Arrays are objects c Arrays are sequences of elements in base type c These elements are collected together in one object: the array c Java includes may other collection mechanisms c Arrays good for some applications (fixed-length sequences), not others (varying-length sequences) c Other collections tuned for different purposes c General observation holds, however: c Collections are objects … c … that contain other objects in a given type c We’ll study two (more in CMSC132): Stack, ArrayList
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 from Bonnie Dorr) 2 for … each … in c New construct available in Java 1.5 (not available in older versions of Java) c Use with arrays c Use with any iteratable collection c Limitations: c modifications limited c can’t add items to the list being iterated over
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 02/05/2009 for the course CMSC 131 taught by Professor Plane during the Fall '08 term at Maryland.

Page1 / 5

18CollectionsLarge - Lecture Set #18: Collections 1. 1. New...

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