Null Pointer Exception after checking with 'if' statement

后端 未结 2 642
逝去的感伤
逝去的感伤 2021-01-15 08:08

I\'m getting a really annoying error, saying I\'m getting a null pointer exception but there\'s an if statement to check to see if the text is null before proceeding:

<
2条回答
  •  北海茫月
    2021-01-15 08:20

     if(Text.equals(null));
    

    The above will throw a NullPointerException each time Text is null. Anytime you use the "." operator on null you get a NullPointerException.

    If you are getting a NPE after if(Text != null), please post the stack trace.

提交回复
热议问题