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

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

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest