Intentionally left blank, bye bye
The problem likely has to do with
AnimalCard. Check that
compareTo is doing what you expect it to do, and that two
AnimalCard instances with different numbers are not considered equal based on this method (i.e. it does not return
0 in such cases). If they are, then that would explain your result, since
TreeMap would simply update the pre-existing entry instead of adding a new one.
Also, if you're debugging, you might want to print the return value of
put() (it could give you some insight as to what's going on).