fre*_*crs 4 java generics instanceof
好的,这是我的类,它封装了一个对象,并将equals和String委托给这个对象,为什么我不能使用???的实例?
public class Leaf<L>
{
private L object;
/**
* @return the object
*/
public L getObject() {
return object;
}
/**
* @param object the object to set
*/
public void setObject(L object) {
this.object = object;
}
public boolean equals(Object other)
{
if(other instanceof Leaf<L>) //--->ERROR ON THIS LINE
{
Leaf<L> o = (Leaf<L>) other;
return this.getObject().equals(o.getObject());
}
return false;
}
public String toString()
{
return object.toString();
}
}
Run Code Online (Sandbox Code Playgroud)
怎么才能让这个工作?谢谢!
| 归档时间: |
|
| 查看次数: |
3045 次 |
| 最近记录: |