Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

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
Avatar of for_yan
for_yan
Flag of United States of America image

String is and Object

In some cases you may say

String s;

Object o = s;

and you don't need to cast as String inherits form Objcet




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

Avatar of gudii9

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
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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