Wiki Markup |
---|
Composition or inheritence may be used to create a new class that both encapsulates an existing class and adds aone variableor ormore field,fields. theWhen valuea ofsubclass whichextends mustanother bethis equalway, forthe objectsconcept of thisequality newfor classthe tosubclass bemay equal.or may Whennot objectsinvolve ofits this new class are equated with objects of the encapsulated class, the new class must override thefields. That is, when comparing two subclass objects for equality, sometimes their respective fields must also be equal, and other times they need not be equal. When objects of a subclass are compared for equality using {{Object.equals()}} method, the subclass must override {{equals()}}.. Furthermore, this method must follow the general contract for {{equals()}} as specified by the Java Language Specification \[[JLS 2005|AA. Bibliography#JLS 05]\]. |
...