Рассмотрим следующий пример:Java генерики - тип выводя
public class GenericTest {
static void print(int x) {
System.out.println("Int: " + x);
}
static void print(String x) {
System.out.println("String: " + x);
}
static void print(Object x) {
System.out.println("Object: " + x);
}
static <T> void printWithClass(T t) {
print(t);
}
public static void main(String argsp[]) {
printWithClass("abc");
}
}
Он печатает объекта: ABC. Почему он не печатает String: abc?
увидеть этот вопрос о получении типа Т - [Get Generic Тип класса во время выполнения] (HTTP: // StackOverflow .com/questions/3403909/get-generic-type-of-class-at-runtime) – csturtz