Home
Cloud
Big Data
CI
Install
Samples
Java
Ubuntu
Maven
Archive
Java
|
HashMap
Notes
Example
Notes
Unsorted entries
Unordered entries
Duplicates elements not allowed
Example
HashMap<Integer, String> hm = new HashMap<>(); hm.clear(); // hm.put(null, "x"); // ok // hm.put(0, null); // OK hm.put(0, "a"); hm.put(11, "f"); hm.put(222, "e"); hm.put(3333, "d"); hm.put(44444, "c"); hm.put(555555, "b"); hm.put(6666666, "g"); for (Map.Entry<Integer, String> entry : hm.entrySet()) { System.out.println(entry.getKey() + " = " + entry.getValue()); }
Output:
0 = a 3333 = d 11 = f 555555 = b 44444 = c 222 = e 6666666 = g
© 2010-2022
mti
tek