It works fine, nothing special, normal use of generics
gt.<String>echoV();
Here we have something less obvious. Since a generic method is defined at runtime, jvm does not know which Generic class will return in compiletime, therefore classTypeException
gt.<String>echoV().getClass();
you should first assign it to a variable since jvm knows the type of the variable in compiletime
String s = gt.<String>echoV(); s.getClass();
source share