I'm trying to create a hashmap which has a String
key and stores an Integer
array.
While using hashmap.get()
, I want to retrieve the stored array.
I've used to following code:
HashMap hm = new HashMap();
String[] arr=new String[]{"-1","-1","-1","-1"};
hm.put("A", arr);
hm.put("B", arr);
hm.put("C", arr);
hm.put("E", arr);
Set set = hm.entrySet();
Iterator i = set.iterator();
while(i.hasNext())
{
Map.Entry me = (Map.Entry)i.next();
System.out.print(me.getKey() + ": ");
System.out.println(me.getValue());
}
The output i'm getting is:
D: [Ljava.lang.String;@88d00c6
E: [Ljava.lang.String;@88d00c6
A: [Ljava.lang.String;@88d00c6
B: [Ljava.lang.String;@88d00c6
C: [Ljava.lang.String;@88d00c6
Can anyone please help!!