小编Hr0*_*419的帖子

我的equals方法输出为true,而它应该为false

我正在编写代码,并遵循给予我的所有指示.当我运行程序但是相同的方法时,所有的代码和方法看起来都很好!基于这些说明,当测试询问点(a,b)---(c,d)是否等于(e,f)---(g,h)时,我应该得到假,但是我得到了真正.谁能让我知道我做错了什么?先感谢您!

 /**
     * The equals method should return true if the given object is equal to the
     * the Object passed in.  Note that this method receives an Object; there is
     * a particular way that this method should be implemented (see notes from class).
     *
     * Notice that two Segments are equal even if their endpoints are swapped
     *  i.e.: (1, 2)---(3, 4) == (3, 4)---(1, 2)
     */

public boolean equals(Object obj) {
        //if (obj instanceof Segment) {
            //Segment …
Run Code Online (Sandbox Code Playgroud)

java methods equals

0
推荐指数
1
解决办法
141
查看次数

标签 统计

equals ×1

java ×1

methods ×1