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

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

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?

Answers

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

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/39106921/how-can-i-retrieve-values-and-keys-from-a-hashmap-in-java-8

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils