previous | start | next

Writing the equals method

        public class TokenPos
        {
           private int level;
           private String token;
           ...
           public boolean equals(Object other) {
             if ( ! (other instanceof TokenPos ) ) {
                return false;
             } else {
               TokenPos tp = (TokenPos) other;
               return token.equals(tp.token) && level == tp.level;
             }
           ...
        }
   


previous | start | next