Java null String equals result

后端 未结 8 727
星月不相逢
星月不相逢 2020-12-16 15:11

Please help me how does the string.equals in java work with null value? Is there some problem with exceptions? Three cases:

boolean result1,result2, result3;         


        
8条回答
  •  爱一瞬间的悲伤
    2020-12-16 15:29

    You will get a NullPointerException in case 1 and case 3.

    You cannot call any methods (like equals()) on a null object.

提交回复
热议问题