Java Collections
2 questions, most-asked first.
How does HashMap work internally?
A lazily-created array of buckets indexed by a spread hash; collisions chain into a linked list that becomes a red-black tree only when the bin holds 8+ nodes AND the table is at least 64 slots.
Asked constantlyintermediate1–8 yrs9 min readWhen would you use LinkedList instead of ArrayList?
Almost never. LinkedList only wins at the ends of the list, and when you need that you want ArrayDeque instead. Its famous advantage — cheap mid-list insertion — is 23x slower than ArrayList on real hardware, because you must walk to the index first.
Asked constantlyintermediate0–8 yrs9 min read