𝗝𝗮𝘃𝗮 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻𝘀: 𝗧𝗵𝗲 𝗛𝗶𝗱𝗱𝗲𝗻 𝗚𝗲𝗺𝘀

A junior dev used LinkedList for a queue. He thought it was the fastest choice. We ran a test. ArrayDeque was ten times faster. Cache locality and less memory use make the difference.

Many devs use the wrong tools. Two hidden features fix this.

EnumSet Stop using HashSet for enums. Use EnumSet.

CopyOnWriteArrayList Use this for thread-safe lists. It stops ConcurrentModificationException.

Use this only when reads happen more than writes.

Review your code today.

Source: https://dev.to/timevolt/java-collections-the-two-features-nobody-talks-about-but-you-should-2fek