title: Java HashSet vs Array Performance
body: <p>I have a collection of objects that are guaranteed to be distinct (in particular, indexed by a unique integer ID).  I also know exactly how many of them there are (and the number won't change), and was wondering whether Array would have a notable performance advantage over HashSet for storing/retrieving said elements.</p>
  
  <p>On paper, Array guarantees constant time insertion (since I know the size ahead of time) and retrieval, but the code for HashSet looks much cleaner and adds some flexibility, so I'm wondering if I'm losing anything performance-wise using it, at least, theoretically.</p>