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!

Should/does <-MyInterface> give MyInterface return types?

843793Jun 1 2003 — edited Jun 2 2003

The variance-overview.pdf says that List<-E> has Object as the return type of the get method. If this is true, I'm disappointed. I'd expect the following to work quite happily:

List<-List<*>> myList = buildList();
List<*> elt1 = myList.get(0);

There's no obvious reason why Object should be a supertype of List.

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 30 2003
Added on Jun 1 2003
5 comments
124 views