{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 circle6 Arrays are collections circle6 Arrays are objects circle6 Arrays are sequences of elements in base type circle6 These elements are collected together in one object: the array circle6 Java includes may other collection mechanisms circle6 Arrays good for some applications (fixed-length sequences), not others (varying-length sequences) circle6 Other collections tuned for different purposes circle6 General observation holds, however: circle6 Collections are objects … circle6 … that contain other objects in a given type circle6 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 Document Right Arrow Icon
2 CMSC 131 Spring 2008 Jan Plane (adapted from Bonnie Dorr) 2 for … each … in circle6 New construct available in Java 1.5 (not available in older versions of Java) circle6 Use with arrays circle6 Use with any iteratable collection circle6 Limitations: circle6 modifications limited circle6 can’t add items to the list being iterated over circle6
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.

{[ snackBarMessage ]}