views:

158

answers:

4

In App Engine, according to the JavaDoc, the getTypeRank method has this signature:

public static int getTypeRank(java.lang.Class<? extends java.lang.Comparable> datastoreType)

In the method signature there is a question mark inside the angle brackets:

<? extends java.lang.Comparable>

What does it signify?

+3  A: 

? essentially indicates a wildcard. <? extends java.lang.Comparable> means "any type that extends java.lang.Comparable (or Comparable itself) can be used here".

Gabe
A: 

? refers to any subclass of java.lang.Comparable. In other words, any class that extends java.lang.Comparable.

lupefiasco
+2  A: 

It's called bounded wildcard

<? extends Comparable> is an example of a bounded wildcard. The ? stands for an unknown type, just like the wildcards we saw earlier. However, in this case, we know that this unknown type is in fact a subtype of Comparable. (Note: It could be Comparableitself, or some subclass; it need not literally extend Comparable.)

More details you find here

stacker
A: 

It means "any class that implements the Comparable interface. Thus, a call would e.g. look like getTypeRank(String.class).

netzwerg