[size=large]
要定义泛型方法,[color=blue]只需将泛型列表置于返回值之前[/color],像这样
public <T> void f(T x){
System.out.println(x.getClass().getName());
}
又或是例如:
public <T> T insert(T obj){
……
return obj;
}
[/size]
要定义泛型方法,[color=blue]只需将泛型列表置于返回值之前[/color],像这样
public <T> void f(T x){
System.out.println(x.getClass().getName());
}
又或是例如:
public <T> T insert(T obj){
……
return obj;
}
[/size]