Collections Corner Cases
summary
Demos use JShell and real JDK APIs to show that map views (keySet, values, entrySet) are view collections backed by map so set/collection operations write through and can remove entries; bulk ops like removeIf and entry.setValue mutate the underlying map. A nested-stream solution for finding keys by common values hits N^2 on 15,000 entries; replacing contains with a HashSet of A’s values reduces it to linear and uses retainAll to compute intersection. Sorted collections use comparators, and a comparator inconsistency with equals makes TreeSet drop “duplicates” (e.g., equal salaries), breaking Set semantics.
AI-written summary · about
chapters (12)
- 0:00Intro
- 0:41Overview
- 1:53View Collections
- 2:48List View of Array
- 7:58Map Key Set View
- 8:34Map Values View
- 8:48Map Entry-set View
- 16:46Extended Map Views Example
- 24:33Solution Attempt #3
- 27:32Iteration Order
- 34:13Set Membership
- 45:45Explanation








