简体   繁体   中英

What's the meaning of the question mark inside the angle brackets: <? extends java.lang.Comparable>

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?

? essentially indicates a wildcard. <? extends java.lang.Comparable> <? 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> <? 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

它意味着“任何实现Comparable接口的类。因此,调用将看起来像getTypeRank(String.class)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM