Reputation: 8905
How to get class object of a generic interface? For example, Boolean.class, Date.class. But List<Boolean>.class doesn't seem to be syntax-valid.
Upvotes: 2
Views: 562
Reputation: 91349
Due to type erasure, your List<Boolean>
will be converted to a simple raw List
at runtime, thus, your best bet is to use List.class
.
Upvotes: 3
Reputation: 66886
Just write List.class
. List<Boolean>
is not of a different type, at runtime. The generic type only exists at compile time. So this imaginary List<Boolean>.class
would not exist to be used in your program.
There is no way to programmatically access the generic type, since it is not present in the byte code. It is only to help the compiler.
Upvotes: 6