Difference between these two conditions?

前端 未结 6 2396
半阙折子戏
半阙折子戏 2020-12-11 08:45

Sorry if my question is silly or not it doesnot matter. But i just want to know what will happen in these two conditions.

public class Test {
    public stat         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-11 09:37

    They do pretty much the same.

    The only difference is that the first example uses the equal() method of the string object "str" with the "test"-string as parameter while the second example uses the equal() method of the string "text" with "str" as parameter.

    The second variant can't throw a NullPointerException since its obviously not null.

提交回复
热议问题