public class GenericMethods {
public <T> void f(T... x) {
System.out.println(x.getClass().getName());
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
GenericMethods gm = new GenericMethods();
gm.f("123", "234");
gm.f(123, 2132);
gm.f(gm, gm);
gm.f(23, "1232", gm);
gm.f("123", 12);
}
}
运行的结果如下:
[Ljava.lang.String;
[Ljava.lang.Integer;
[Lcom.test.generic.Method.GenericMethods;
[Ljava.lang.Object;
[Ljava.io.Serializable;//此行为什么不是Object?
|