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

后端 未结 4 1787
后悔当初
后悔当初 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:12

    Basically, instanceof askes for an object as left operand. Primitive variables are not objects, so no, you can't use it that way.

提交回复
热议问题