user840930 user840930 - 1 year ago 65
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 Source
for (final Map.Entry<String, Object> entry : hashmap.entrySet()) {
       final String key = entry.getKey();
       System.out.println("Key:" + key);
       Object obj = entry.getValue();
}