Friday, May 27, 2011

Map.Entry interface methods (java)

Each element is a map has a key and value. Each key-value pair is saved in a java.util.Map.Entry object. A set of these map entries can be obtained by calling a map's entrySet() method. Iterating over a map is done by iterating over this set.
Assume in the following table that me is a Map.Entry object.
ResultMethod Description
obj = me.getKey() Returns the key from the pair.
objme.getValue(key) Returns the value from the Map pair.
objme.setValue(val) This is an optional operation and may not be supported by all Map.Entry objects. Sets the value of the pair, which modifies the Map which it belongs to. Returns the orginal value.

No comments:

Post a Comment