In Java, can I use a primitive type literal or type variable in an instanceof expression?

后端 未结 4 1783
后悔当初
后悔当初 2021-01-07 03:11

Can I use a primitive type literal or type variable in an instanceof expression?

class MyClass {
    {
         boolean b1 = null insta         


        
4条回答
  •  清酒与你
    2021-01-07 04:07

    1. Due to type erasure, you cannot know what T is.

    2. Literals (except for string literals) aren't objects.
      Therefore, no.

提交回复
热议问题