title: Java Array/List with stable index on remove
body: <p>I'm looking for a data structure like <code>ArrayList</code> which elements don't get reindexed after removing a single one from it.</p>
  
  <p>As an example scenario, Consider having a list as following <strong>psoudocode</strong>:</p>
  
  <pre><code>A(0) = m
  A(1) = n
  A(2) = o
  A(3) = p
  A(4) = q
  </code></pre>
  
  <p>Using <code>ArrayAdapter</code>, issuing a <code>A.remove(2)</code> results in:</p>
  
  <pre><code>A(0) = m
  A(1) = n
  A(2) = p      // index decremented
  A(3) = q      // index decremented
  </code></pre>
  
  <p>which is not my desired behaviour. I'm looking for a list/array/map/set/collection/whatever which gives a result like this:</p>
  
  <pre><code>A(0) = m
  A(1) = n
  A(3) = p      // index persisted
  A(4) = q      // index persisted
  </code></pre>
  
  <p>It "can" be done using a integer counter combined with a <code>Map</code> but i'm wondering if a cleaner solution is already available.</p>
  
  <p>Dirty approach using Map and integer counter:</p>
  
  <pre><code>HashMap&lt;Integer, Object&gt; map = new HashMap&lt;&gt;();
  int indexCounter = 0;
  
  public void insertItem(Object o){
      map.put(indexCounter, o);
      indexCounter++;
  }
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Edit: 
  To clearify, by <code>m, n, o, ...</code> i mean different values. These are not necessarily string and can be any kind of objects. That's a pseudocode.</p>
  
  <p>More than that, Using NULL or mock values would not be an option in my case. Although, i'm looking for a general solution, not a specific one for my case. Thanks for sharing btw.</p>
  
  <p>Edit 2:
  Actually, im looking for a data structure, not a hack or trick. Thus, if there is not such a thing provided in Java, the correct answer to this question would be a straight conclusive "No, there isn't such a thing".</p>