简体   繁体   English

什么是java.lang.Class <?> []

[英]what is java.lang.Class<?>[]

What is java.lang.Class<?>[] in java . 什么是java中的java.lang.Class<?>[] Specifically what is <?> . 具体是什么<?>

I am a beginner in java , I cannot figure out what is the meaning of <?> 我是java的初学者,我无法弄清楚<?>的含义是<?>

Thanks, 谢谢,

Puneet 普尼特

A type argument for a parameterized type is not limited to a concrete class or interface. 参数化类型的类型参数不限于具体的类或接口。 Java allows the use of type wildcards to serve as type arguments for parameterized types. Java允许使用类型通配符作为参数化类型的类型参数。 Wildcards are type arguments in the form "?", possibly with an upper or lower bound. 通配符是“?”形式的类型参数,可能带有上限或下限。 Given that the exact type represented by a wildcard is unknown, restrictions are placed on the type of methods that may be called on object of the parameterized type. 假定通配符表示的确切类型未知,则对可在参数化类型的对象上调用的方法类型进行限制。

Source: Generics In Java 来源: Java中的泛型
Also: Wildcards in Generics 另外: 泛型中的通配符

Instances of the class Class represent classes and interfaces in a running Java application. 类Class的实例表示正在运行的Java应用程序中的类和接口。 The <?> part indicates that a Class can be a represantation of any java object, basicly. <?>部分表示一个Class可以是任何java对象的represantation,基本上。 This is Java Generics. 这是Java Generics。

<?> means any type. <?>表示任何类型。

Since all java classes directly/indirectly inherit Object , you can simply think of <?> as <Object> , although this is not so precise. 由于所有java类都直接/间接地继承了Object ,因此您可以简单地将<?>视为<Object> ,尽管这不是那么精确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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