title: Best Java Collection to store key, value pairs and access its objects by Index or by key name
body: <p>I want to store a key,values pair that allows me to get the values by its position (ordering must persist) or by its key name. I was thinking to use HashMap but i do not want to iterate through all values to get the value by index. </p>
  
  <p>I would need something like this:</p>
  
  <pre><code>MyCollection&lt;String, Object&gt; objects = new MyCollection&lt;String, Object&gt;();
  objects.put ("id", Object1);
  objects.put ("name", Object2);
  // And now access the values by index:
  Object obj1 = objects.get(1);
  // or by key name:
  Object obj2 = objects.getByKeyName("name");
  </code></pre>
  
  <p>What is the best collection to use (it must be android &lt; 11 compatible></p>