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;
Our most common use-case of this type of thing is when we have a database field that contains "Y" or "N" to represent a Boolean (it's an old system, don't ask).
Thus, we do this:
if ("Y".equals(stringObjectThatMayBeNull) ? result : otherResult);
Instead of this:
if (stringObjectThatMayBeNull.equals("Y") ? result : otherResult);
... which avoids a NullPointerException when executing the .equals method.