Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2><a href="https://docs.oracle.com/javase/7/docs/api/java/util/AbstractMap.SimpleEntry.html" rel="noreferrer">AbstractMap.SimpleEntry</a></h2> <p>Easy you are looking for this:</p> <pre><code>java.util.List&lt;java.util.Map.Entry&lt;String,Integer&gt;&gt; pairList= new java.util.ArrayList&lt;&gt;(); </code></pre> <p>How can you fill it?</p> <pre><code>java.util.Map.Entry&lt;String,Integer&gt; pair1=new java.util.AbstractMap.SimpleEntry&lt;&gt;("Not Unique key1",1); java.util.Map.Entry&lt;String,Integer&gt; pair2=new java.util.AbstractMap.SimpleEntry&lt;&gt;("Not Unique key2",2); pairList.add(pair1); pairList.add(pair2); </code></pre> <p>This simplifies to:</p> <pre><code>Entry&lt;String,Integer&gt; pair1=new SimpleEntry&lt;&gt;("Not Unique key1",1); Entry&lt;String,Integer&gt; pair2=new SimpleEntry&lt;&gt;("Not Unique key2",2); pairList.add(pair1); pairList.add(pair2); </code></pre> <p>And, with the help of a <code>createEntry</code> method, can further reduce the verbosity to:</p> <pre><code>pairList.add(createEntry("Not Unique key1", 1)); pairList.add(createEntry("Not Unique key2", 2)); </code></pre> <p>Since <code>ArrayList</code> isn't final, it can be subclassed to expose an <code>of</code> method (and the aforementioned <code>createEntry</code> method), resulting in the syntactically terse:</p> <pre><code>TupleList&lt;java.util.Map.Entry&lt;String,Integer&gt;&gt; pair = new TupleList&lt;&gt;(); pair.of("Not Unique key1", 1); pair.of("Not Unique key2", 2); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload