logo

New Response

« Return to the blog entry

You are replying to:

    • avatar
    • axel
    • Posted on Wed 14 Dec 2011 11:11 AM

    I second Peter.

    TreeSet is in Java1.3.

    java.util.Sets just call the equal methods of the objects that are allready member of the Set.

    They manage sorting by calling the compareTo method.

    And BillingAdress has all it needs: compareTo AND equals method overriden.

    Hm. Well there is something missing, that may generate nasty behaviour: You should ALLWAYS implement hashCode method whenever you override equals.

    http://www.xyzws.com/javafaq/why-always-override-hashcode-if-overriding-equals/20

    I allways use eclipse to implement this kind of stuff.

    Source/Generate Hash Code and Equals,

    Source/Generate ToString

    Source/Generate Setters and Getters.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: