What's the meaning of the question mark inside the angle brackets:

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?

1

4 Answers

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

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

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

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like