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.


Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -

jquery - jqGrid update specific column data with out refreshing the entire column? -