• 中文
    • English
  • 注册
  • 查看作者
    • 《算法第四版》课后练习题1.2.14答案

      习题1.2.14

      用我们在Date中的equals()方法的实现(请见1.2.5.8节中的Date类代码框)作为模板,实现Transaction开发equals()方法。

      要点分析

      Date的equals()方法

      请见1.2.5.8节的具体实现。(课本第65页)

      参考答案

       @Override
          public boolean equals(Object other) {
              if (other == this) return true;
              if (other == null) return false;
              if (other.getClass() != this.getClass()) return false;
              Transaction that = (Transaction) other;
              return (this.amount == that.amount) && (this.who.equals(that.who))
                                                  && (this.when.equals(that.when));
          }
    • 0
    • 0
    • 0
    • 2k
    • 海贼王

      请登录之后再进行评论

      登录

      赞助本站

      • 支付宝
      • 微信
      • QQ

      感谢一直支持本站的所有人!

      单栏布局 侧栏位置: