Difference between Class and Class<?>

后端 未结 4 2108
长情又很酷
长情又很酷 2021-02-01 13:10

What is the difference between a Class and a Class declaration.

  • Class a;
  • Class b;
4条回答
  •  旧时难觅i
    2021-02-01 13:50

    Class javadoc:

    Type Parameters: T - the type of the class modeled by this Class object. For example, the type of String.class is Class. Use Class if the class being modeled is unknown.

    Use of Class without the type parameter is similar to using any generic class (Map, List, etc.) without the type parameter - either it's a pre-1.5 legacy usage or it's just a segment of code that does not care about unchecked type casting.

提交回复
热议问题