{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

15SetsMaps - CMSC 132 Object-Oriented Programming II Sets...

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

View Full Document Right Arrow Icon
1 CMSC 132: Object-Oriented Programming II Sets and Maps Department of Computer Science University of Maryland, College Park
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 How Do Collections Work in Java? Elements are NOT copied when inserted Collection contains references, not objects Finding matching element is based on equals( ) To build a collection for a class Need to define your own equals(Object) method Default equals( ) uses reference comparison Just like a == b a and b are only equal if they refer to the same object
Background image of page 2
3 Sets Properties Collection of elements without duplicates No ordering (i.e., no front or back) Order in which elements added doesn’t matter Implementation goal Offer the ability to find / remove element quickly Without searching through all elements Set B Set C Set A
Background image of page 3

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

View Full Document Right Arrow Icon