"String".equals(str)
Does not give the same result as
str.equals("String")
if str == null.
In the first case, it returns false, and in the second - a NullPointerException.
"String".equals(str)
Actually equivalent
str != null && str.equals("String")
njzk2 source
share