Class object of generic class (java)

前端 未结 7 916
时光说笑
时光说笑 2020-11-27 03:17

is there a way in java to get an instance of something like Class> ?

相关标签:
7条回答
  • 2020-11-27 03:44

    Because of type erasure, at the Class level, all List interfaces are the same. They are only different at compile time. So you can have Class<List> as a type, where List.class is of that type, but you can't get more specific than that because they aren't seperate classes, just type declarations that are erased by the compiler into explicit casts.

    0 讨论(0)
提交回复
热议问题