Why “t instanceof T” is not allowed where T is a type parameter and t is a variable?

后端 未结 7 1707
Happy的楠姐
Happy的楠姐 2021-01-05 11:03

Eclipse says that the instanceof operation is not allowed with Type Parameter due to generic type eraser.

I agree that at runtime, no type information stays. But con

相关标签:
7条回答
  • 2021-01-05 11:49

    Java realize its Generics using "Erasure", it can check the type and delete the type parameter information in "COMPILE TIME", in "RUN TIME" there will only the BOUNDARIES of the type parameters, so there will not be any thing like "Integer"

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