user840930 user840930 - 3 months ago 17
Java Question

How can I retrieve values and keys from a HashMap in Java 8?

I tried to use an Iterator but Iterator.next() gives me an int. Not sure what to do with an int. How can I get the keys and values?

Answer
for (final Map.Entry<String, Object> entry : hashmap.entrySet()) {
       final String key = entry.getKey();
       System.out.println("Key:" + key);
       Object obj = entry.getValue();
}