@ SuppressWarnings ( "all" ) public class GJClass T { public String getClassName ( T t ){ return t . getClass (). getName (); } } 测试类public class test76 { public static void main ( String [] args ){ GJClass gjClass = new GJClass (); S
@SuppressWarnings("all")
public class GJClass<T> {
public String getClassName(T t){
return t.getClass().getName();
}
}
测试类public class test76 {
public static void main(String[] args){
GJClass gjClass=new GJClass();
String className=gjClass.getClassName(new Employee());
System.out.println(className);
GJClass<Integer> gjClass1=new GJClass<Integer>();
String className1=gjClass1.getClassName(new Integer(100));
System.out.println(className1);
}
}
运行结果