I'm trying print out a a simple hash map with a string key and char array except I'm not getting the proper output.
Output basically goes:
Key :3 Value :[C@35960f05
Key :2 Value :[C@35960f05
Key :1 Value :[C@35960f05
Which I guess is the code the char arrays actual location? I didn't google because I'm honestly not sure what this means or what it's called. Could please someone tell me how to fix this or where I might find information so I can find my own solution. Here is my code:
public class MapExample {
public static void main(String[] args) {
Map<String, char[]> mp = new HashMap<String, char[]>();
char[] words = new char[3];
words[0] = 'a';
words[1] = 'b';
words[2] = 'c';
mp.put("1", words);
mp.put("2", words);
mp.put("3", words);
Set s = mp.entrySet();
Iterator it = s.iterator();
while (it.hasNext()) {
Map.Entry m = (Map.Entry) it.next();
String key = (String) m.getKey();
char[] value = (char[]) m.getValue();
System.out.println("Key :" + key + " Value :" + value);
}
}
}