直接上代码
class Worker
{
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
class Tool<TT>
{
public void show(TT t)
{
Object obj=(Object)t;
System.out.println(obj.toString());
}
}
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Tool<Worker> tw=new Tool<Worker>();
Worker w=new Worker();
w.setAge(1);
w.setName("aaa");
tw.show(w);
}
}
问题: 如何根据穿进去的对象获取到Worker对象里的数据 我没办法获取到 谢谢 |