aspose file tools*
The moose likes Java in General and the fly likes Question about Types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Question about Types" Watch "Question about Types" New topic
Author

Question about Types

Bob Sherry
Greenhorn

Joined: Jun 27, 2008
Posts: 20
Please consider the following Java program:

import java.util.*;
public class BackLister {
public static<T> List<T> backward(List<? extends T>input)
{
List<T> output = new LinkedList<T>();
for(T t : input )
output.add(0, t);
return output;
}
}

I do not understand the use of the question mark in declaring the
method backward. I am hoping that somebody can explain it to me.

Thanks

Bob
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40058
    
  28
It means you can use an unspecified type there, which might be the same a T, or a subclass of T (or if T is an interface, something implementing T).

Go through the Java Tutorials (look for "wildcards") for lots more detail.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about Types