Returning false from Equals methods without Overriding

后端 未结 3 856
隐瞒了意图╮
隐瞒了意图╮ 2021-01-29 13:46

Write TestEquals class so that main method of Puzzle3 class prints false.

Note: You cannot override equals method o

3条回答
  •  孤城傲影
    2021-01-29 14:20

    Instead of overriding equals you can overload equals

    class TestEquals {
        // a common mistake which doesn't override equals(Object)
        public boolean equals(TestEquals te) { 
              return false;
        }
    }
    

提交回复
热议问题