又出现问题了,又是编译的时候出现异常了,这个问题是怎么解决呢搞得我很郁闷代码如下://泛型类
class Utils<QQ>
{
private QQ q;
public void Object(QQ q)
{
this.q=q;
}
public QQ getObject()
{
return q;
}
}
class GenericDemo2
{
public static void main(String[] args)
{
Utils<Worker> u=new Utils<Worker>();
u.setObject(new Worker());
Worker w=u.getObject();
/*
Tool t=new Tool();
t.setObject(new Student_2());
Worker w=(Worker)t.getObject();
*/
}
}
泛型类的问题,编译时出现的异常如下:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method setObject(Worker) is undefined for the type Utils<Worker>