A HashMap (or Map in general) uses key/value pairs. When you add something to the map you must specify a key and it is that key that is used again later when retrieving the value. Based on the implementation of the HashMap, given a key, retrieval of a value is done in O(1) time.
containsValue is a useful method for checking that a HashMap contains the value you are looking for, but I don't really see why you are using that to retrieve the value you are looking for??
The correft way to use a map would be something like:
HashMap<Integer, Object> myMap = new HashMap<Integer, Object>();
myMap.put(1, object1);
myMap.put(2, object2);
myMap.put(3, object3);
Now you can get your objects by doing:
Object myObject = myMap.get(1);
If you did:
myMap.containsValue(1);
this would return false, as 1 is the key, not the value. You could do:
myMap.containsKey(1);
if you just want to know if it exists, but there is no problem in calling:
Object myObject = myMap.get(99);
it would just return null if there was no key, 99.
So basically, the point is, you are correct, there is no point in using containsValue when you are trying to retrieve the value. Use get or containsKey if you want to check for existence first.