Java LinkedHashMap keep the insertion order

Description

Java LinkedHashMap keep the insertion order

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

public class Main {
  public static void main(String[] args) {
    Map<String,String> lHashMap = new LinkedHashMap<String,String>();

    lHashMap.put("1", "CSS");
    lHashMap.put("2", "HTML");
    lHashMap.put("3", "Java");

    Collection<String> c = lHashMap.values();
    Iterator<String> itr = c.iterator();

    while (itr.hasNext()){
      System.out.println(itr.next());
    }/*from w  w w.  ja  va2s  .  c  o m*/
  }
}



PreviousNext

Related