How to use iterator in LinkedHashmap
Previous | Home | Next |
This program shows the iterator in the LinkedHashMap.
This program shows the iterator in the LinkedHashMap.
This program shows the iterator in the LinkedHashMap.
This program shows the iterator in the LinkedHashMap.
// the diiference between hashmap and linked hashmap is that
//hashmap doesn't ensures the order of iteration while
//linked Hashmap returns the value in same order as value pass to the Map.
package Example;
import java .util.Collection;
import java .util.Iterator;
import java .util.LinkedHashMap;
public class ItLinkedHmap {
/**
* @param args
*/
public static void main(String[] args) {
LinkedHashMap lhmp=new LinkedHashMap();
lhmp.put("12","twelve");
lhmp.put("13","thirteen");
lhmp.put("14","forteen");
Collection c=lhmp.values();
Iterator it= c.iterator();
while (it.hasNext())
System.out.println(it.next());
// TODO Auto-generated method stub
}
}
twelve
thirteen
forteen
Previous | Home | Next |