~/talk

Java ArrayLists Are Not Magical

TalkinFrenchat Devoxx France 2022 · 2022-04-20..04-22· [java]
links:none on file
slides:none on file

Explains how java.util.ArrayList uses an Object[] backing array that grows by a 1.5× factor so resizes are geometric and individual add operations are amortized O(1). Shows that calling ensureCapacity or addAll avoids repeated resizes (benchmarks about 5× faster than naive per-element adds), that remove(index) shifts the tail and nulls the freed slot for GC, that removeIf is much faster than repeated remove calls, and notes CopyOnWriteArrayList copies the array on each write and Project Valhalla aims to provide faster primitive-style collections.

AI-written summary · about

  1. 0:00Introduction
  2. 0:22Why study ArrayLists
  3. 1:04ArrayList internals
  4. 2:30Add element cost
  5. 4:37Add methods compared
  6. 5:21Removing elements
  7. 6:46Remove methods benchmark
  8. 7:09Java list comparison
  9. 8:39Mutable set pitfalls
  10. 9:21List traversal risks
  11. 10:50CopyOnWriteArrayList concurrency
  12. 11:53Modifying during traversal
  13. 12:14Valhalla future performance
  14. 12:59Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.