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
3 Sets Properties Collection of elements without duplicates No ordering (i.e., no front or back) Order in which elements added doesn’t matterImplementation goal Offer the ability to find / remove element quickly Without searching through all elements Set B Set C Set A
has intentionally blurred sections.
Sign up to view the full version.