The HashMap is working fine. Just because you make two new objects with the same name, doesn't mean the computer thinks they are the same object.
Try the following:
man1 = new Man("John");
man2 = new Man("John");
if (man1 == man2) {
System.out.println("Equal");
} else {
System.out.println("Not equal");
}
You'll get "not equal" because the computer is checking to see if they are exactly the same object, not just named the same.
Each time you're using the "new" keyword, you're declaring a new object and the computer gives it a unique address.
Try this:
man1 = new Man("John");
HashMap<Man, Double> myList = new HashMap<>();
myList.put(man1, "5.00");
System.out.print.ln(myList.get(man1));
you'll see you now get "5.00" back because you're actually giving it the exact object that is the key in the map.
You'll need to define manually how you decide that two "men" are equal if you want the behavior to work like this. You might be better off using a full name as a key, since that's usually going to be unique, and less work for you to implement.