The Artima Developer Community
Sponsored Link

Computing Thoughts
Why no <T super Fruit> ?
by Bruce Eckel
November 9, 2005
Summary
I'm hoping this is an obvious one and that my brain is just fried from over-generification.

Advertisement

I haven't even found a mention of supertype bounds in any of the basic references, except with the use of wildcards. Perhaps the reason is so apparent that no one even points it out, but I hope I can at least see an example of why this is.

You can say:


class SubtypeBound<T extends Fruit> {}
But you can't say:

class SupertypeBound<T super Fruit> {}

Why not?

Talk Back!

Have an opinion? Readers have already posted 7 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Bruce Eckel adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Bruce Eckel (www.BruceEckel.com) provides development assistance in Python with user interfaces in Flex. He is the author of Thinking in Java (Prentice-Hall, 1998, 2nd Edition, 2000, 3rd Edition, 2003, 4th Edition, 2005), the Hands-On Java Seminar CD ROM (available on the Web site), Thinking in C++ (PH 1995; 2nd edition 2000, Volume 2 with Chuck Allison, 2003), C++ Inside & Out (Osborne/McGraw-Hill 1993), among others. He's given hundreds of presentations throughout the world, published over 150 articles in numerous magazines, was a founding member of the ANSI/ISO C++ committee and speaks regularly at conferences.

This weblog entry is Copyright © 2005 Bruce Eckel. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use