I want to create a HashMap which is having the key as 1,2,3..... and the value as strings. When i try adding it, i could find only the put method whioch takes only the objects as the input. Can anyone please tell me hiow can i add these strings and integer values into the hashmap table. Thanks.
renu richard wrote: . . . I want to know how to which variable i can assign this to.Can i do something like
Yes, as long as the compiler knows you are returning an Integer. It will work in Java5 if you declare the Map as Map<Something, Integer> and instantiate it with the types too. In Java1.4 and older, you would have to use a class cast and some method of the Integer class to get the value.