Just started with Java generics and I am little confused. I read the tutorial but there are still some things I don't get.
The following code works (no surprise there):
TypeVariable<Class<String>>[] foo =
String.class.getTypeParameters();
but when I do the following:
Class<? extends String> foo = "".getClass();
TypeVariable<Class<? extends String>>[] bar = foo.getTypeParameters()
I get :
incompatible types
found : java.lang.reflect.TypeVariable<java.lang.Class<capture of ? extends java.lang.String>>[]
required: java.lang.reflect.TypeVariable<java.lang.Class<? extends java.lang.String>>[]
I can get it to work with wildcards (TypeVariables<?> bar = ...) but I would like to know that this "capture of ? extends String" actually means. And what syntax should be used.
--
Magnus