HashMaps and multiple values 1 key

Discussion in 'Plugin Development' started by brord, Dec 12, 2012.

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

    brord

    So I try to store some data in a HashMap, but it can occur that 1 name needs to have x2 values.
    Currently, i do it like this:

    HashMap<String, ArrayList<String>> assistedPlayers = new HashMap<String, ArrayList<String>>();
    And check IF the key is set. IF it is, get the Value(ArrayList), add new String and set it again, overriding the old one.

    The question is: IS this the best way to do this, or is there something i do not know of, which i should use?

    Thanks!
     
  2. Offline

    fireblast709

    As HashMaps do not accept duplicate keys, I would say yes
     
  3. Offline

    brord

    Okay thanks!
    Just wondering, what plugins did you make?
    Since you seem to be skilled in java :3
     
  4. Offline

    fireblast709

    never released stuff so far ;3
     
Thread Status:
Not open for further replies.

Share This Page