Get the previous element of a LinkedHashMap
<p>I need to get the previous element of a LinkedHashMap. 
I tried using the ListIterator because it has the previous() method. But the problem is ListIterator needs a List not a set. </p>

<pre><code>ListIterator&lt;Entry&lt;String, Integer&gt;&gt; it = (ListIterator&lt;Entry&lt;String, Integer&gt;&gt;) unitsItems.entrySet().iterator();
</code></pre>

<p>I have to transform my entrySet into a list. So I tried this :</p>

<pre><code>List entryList= new ArrayList (unitsItems.entrySet());
     ListIterator&lt;Entry&lt;String, Integer&gt;&gt; it = (ListIterator&lt;Entry&lt;String, Integer&gt;&gt;) entryList.iterator();
</code></pre>

<p>I got this error: </p>

<pre><code>java.util.ArrayList$Itr cannot be cast to java.util.ListIterator
</code></pre>

<p>Can anyone tell me the correct way to transform the set to a list and then use it in ListIterator?
Thank you. </p>