Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Capture of ? extends... compilation error

843793May 1 2005 — edited May 10 2005
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2005
Added on May 1 2005
10 comments
1,397 views