OK이 클래스는 클래스이며, 객체를 캡슐화하고, 위임자와이 객체에 대한 String을 위임합니다. 왜 인스턴스를 사용할 수 없습니까?Generics and instanceof - java
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();
}
}
어떻게하면 되나요? 감사합니다.
어쩌면 당신은 당신이 instanceof를 사용할 수없는 것은 – dimitrisli