我无法在私有方法中调用正确的参数。
MyIntSET
是Node
,因此我无法调用MyIntSET
,而是调用root
...我仍然在Eclipse中收到错误说明:"This method must return a result of type boolean"
有什么建议吗?
/* Returns true if this tree and that tree "look the same." (i.e. They have
* the same keys in the same locations in the tree.)
* Note that just having the same keys is NOT enough. They must also be in
* the same positions in the tree.
*/
***更新:我在我的公开声明中添加了一个返回虚假声明**** 我运行了一个JUnit测试,但仍然失败了......
我错过了什么?
答案 0 :(得分:0)
您获得的错误是因为如果if条件不,则需要指定treeEquals
返回的内容,如果根目录不是null
则需要继续并比较两次尝试
试试这个
public boolean treeEquals(MyIntSET that) {
if (root == null && that.getRoot() == null)
return true;
return treeEquals(root, that.getRoot());
}
假设您有MyIntSET
类