This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
swaraj gupta wrote:doesn't TreeSet uses equals() to test equality of two objects...?
where I can read about this?
No. And the JavaDoc for TreeSet states this in one of the first few paragraphs. The JavaDoc further states that the comparator/comparable must also be "consistent with equals", meaning it will assume that the comparable/comparator methods can be used instead of equals -- no further checking is done.