Loop through HashMap and get Key and Value?

Discussion in 'Plugin Development' started by NerdsWBNerds, May 12, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    NerdsWBNerds

    So I have a HashMap and I want to look through it and get both the Key (String) and Value (Boolean). This way I can make a list of all the possible booleans that are current in the HashMap, is there any way I can do this?
     
  2. Offline

    Njol

    You can use HashMap.entrySet() to get all key/value pairs stored in the hashmap:
    Code:java
    1. HashMap<K, V> hashmap = ...;
    2. for (Entry<K, V> : hashmap.entrySet()) {
    3. // code here
    4. }
     
    PDKnight likes this.
  3. Offline

    NerdsWBNerds

Thread Status:
Not open for further replies.

Share This Page