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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -