class Generic<T> {
void method(T t) {
print(t.getClass().getSimpleName());
}
}
public class Program {
static public void main(String[] args) {
Generic<String> g = new Generic1<>();
g.method(new String());
}
}
As expected, the output is String
. Why was the information about type saved if the type erasure was happened? If I understand it correctly, the output should have been Object
.