• Home
  • LLMs
  • Python
  • Docker
  • Kubernetes
  • Java
  • Maven
  • All
  • About
Java | LinkedHashMap
  1. Notes
  2. Example

  1. Notes
    Ordered entries
    Duplicates elements not allowed
  2. Example
    LinkedHashMap<Integer, String> lhm = new LinkedHashMap<>();
    
    lhm.clear();
    // lhm.put(null, "a"); // OK
    // lhm.put(0, null); // OK
    lhm.put(0, "a");
    lhm.put(44444, "c");
    lhm.put(555555, "b");
    lhm.put(3333, "d");
    lhm.put(11, "f");
    lhm.put(222, "e");
    lhm.put(6666666, "g");
    
    for (Map.Entry<Integer, String> entry : lhm.entrySet()) {
        System.out.println(entry.getKey() + " = " + entry.getValue());
    }
    Output:
    0 = a
    44444 = c
    555555 = b
    3333 = d
    11 = f
    222 = e
    6666666 = g
© 2025  mtitek