title: How does an ArrayList retrieve data in constant time?
body: <p>One interview question which I couldn't answer and couldn't find any relevant answers online.</p>
  
  <p>Suppose in an arraylist, there are 10000 data, and I want to find the number which is currently on 5000th index, how does the arraylist know the indexes and give result in constant time?</p>
  
  <p>Because if we are traversing through the arraylist to find the data, it would take linear time and not constant time.</p>
  
  <p>Thanks in advance.</p>