How can I get the key for a specific value in a HashMap?


Possible Duplicate:
Java Hashmap: How to get key from value?

I have a hashmap

private static HashMap<ObjectClass, UUID> projectileSet = new HashMap<ObjectClass, UUID>();

and an unfinished method where i want to return the ObjectClass that corresponds to the UUID

public static LegendaryItem getClass(UUID uniqueId) {
    return projectileSet.getKey(uniqueId);


You can return key from HashMap by using "KeySet()" method.

HashMap objH=new HashMap<>();
Set objSet=objH.keySet();
public static LegendaryItem getClass(UUID uniqueId) {
    Iterator objItr=objSet.iterator();
        UUID objStr=(UUID);
            return objStr;

Iterate the ObjSet and get each key