java - Why can't we add BigDecimal to TreeSet ? -
this question has answer here:
i read somewhere can't add bigdecimal treeset because incorrectly implements compareto method , e.g. 9.0 , 9.00 , return 0 , although using equals method return false. seems reason. can explain in bit more detail ?
equals()
in case return false because precision different. compareto()
return 0 because "value" same.