Java LinkedHashMap class

Introduction

LinkedHashMap tracks the order of insertion for map.

import java.util.LinkedHashMap;
import java.util.Map;

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

    map.put("Javascript", 0);
    map.put("CSS", 1);
    map.put("HTML", 2);
    map.put("Java", 3);
    map.put("SQL", 4);

    for (Map.Entry<String, Integer> entry : map.entrySet()) {
      System.out.println(entry.getKey() + " => " + entry.getValue());
    }//from w  w w .ja v  a2 s .  c om
  }
}



PreviousNext

Related