Test test = new Test() {}; there's nothing in {},why the result is different.
public class Test<T> {
private final TypeToken<T> typeToken = new TypeToken<T>(getClass()) {};
private final Type type = typeToken.getType();
public void foo() {
System.out.println(this.type);
}
public static void main(String[] args) {
Test<Integer> test = new Test<Integer>() {};
Test<Integer> test2 = new Test<Integer>();
test.foo();// class java.lang.Integer
test2.foo();//T
}
}
Aucun commentaire:
Enregistrer un commentaire