File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Generics - what does it mean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Generics - what does it mean "? super T"?" Watch "Generics - what does it mean "? super T"?" New topic
Author

Generics - what does it mean "? super T"?

Mateus Lucio
Ranch Hand

Joined: Jul 27, 2006
Posts: 57
Hi folks!
I understood what <? extends T> means that ? is subtype of T, in other words ? extends or implements T, but what about the super?
does it mean that ? is supertype of T??? I really didnt catch that!!!

I'd appreciate if you guys explained it to me!
thanks in advance!!


Studying ...
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Yes, it means T or a superclass of T.
Mateus Lucio
Ranch Hand

Joined: Jul 27, 2006
Posts: 57
By superclass you mean only extention (extends)? or it works for interfaces too?

by the way, if its not asking too much could give me an exemple of a situation where I'd take advantage of this?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Yes it also works for superinterfaces.

Here is an example of using the lower bounded wildcard.


[ November 08, 2006: Message edited by: Keith Lynn ]
Mateus Lucio
Ranch Hand

Joined: Jul 27, 2006
Posts: 57
I see! ... thank you very much!
I understand it, now I'll write and run some code to master it (or be as close as possible)

Thanks again!
zero Corner
Greenhorn

Joined: Nov 23, 2009
Posts: 4
i am totally new in the Generic type in java, i don't really get what does the ? mean

public static <T extends Comparable<? super T>> void bubbleSort(T[] a, int n)

1)what does <T extends Comparable<? super T>> really mean? declaring the Generic T for the compiler to recognize it?
2) what does ? really for?

thank you in advance...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

Zero Corner, you have been warned about your name twice before. This is your last warning. Change it to something appropriate or your account will be closed.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics - what does it mean "? super T"?