This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates 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.