gudii9
asked on
Object from String
I would like to know
how to get object from a string
and
also when do we use
map.keySet().
Thanks in advance
how to get object from a string
and
also when do we use
map.keySet().
Thanks in advance
http://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.html#keySet%28%29
map.keySet() is a method which returns set of keys for a given object of type Map
ASKER
>>>keySet
public Set keySet()
Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.
Returns:
a set view of the keys contained in this map.
when do we use it. To change map to set we use it?
Please elaborate
public Set keySet()
Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.
Returns:
a set view of the keys contained in this map.
when do we use it. To change map to set we use it?
Please elaborate
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No we usualyy don't use keySet() to change the map,
we'll chnge the map normally by addig new pairs, say with put(kew, Vlaue) method
we'll chnge the map normally by addig new pairs, say with put(kew, Vlaue) method
In some cases you may say
String s;
Object o = s;
and you don't need to cast as String inherits form Objcet