这就是我目前的方法:
//this method should check if the pokemon are equal//
public boolean equals(Pokemon other){
boolean equality;
if (**XXXXX** == other)
equality = true;
else
equality = false;
return equality;
}
所以这应该比较两个对象,但我的问题是如何调用该方法所应用的对象?例如,主代码应该将此 equals 方法应用于 Pokemon a,如下所示:
if (a.equals(other))
System.out.println("Pokemon are equal!");
如何在我的方法中输入或调用“a”(应用该方法的对象),以便比较它们是否相等?因为当我将代码中的XXXXX替换为如下所示:
if (Pokemon == other)
equality = true;
我得到错误:
Pokemon.java:130: error: cannot find symbol
if ( Pokemon == other)
^
symbol: variable Pokemon
location: class Pokemon