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.