Q:

Java8: Hashmap overriden tostring behaviour

I have a hash map in java 8. I want to print reference of hash map instead of its content. In java 8 when I print hash map using its to String method it prints content. How can I get object reference printed?
Map<String,String> m = new HashMap<String,String>();
m.put("abc","def");
System.out.println("m is"+m); //need to get object reference not content

A:

You can do this to get what the Object.toString method would return:
String s = m.getClass().getName() + "@" + Integer.toHexString(m.hashCode());
System.out.println(s);

