Can anyone here confirm that Java doesn't necessarily perform each conditional in an "if" statement, if the first few parts of it will determine its outcome?
For example, if I have three conditionals ANDed together and the first one is false, then are the other two tested?
The reason I ask is I have a multiple OR conditional and one of the conditions might result in a NullPointerException if it is executed. I do have a test for nulls earlier in the expression.
My assumption is that:
...will never give a NullPointerException, but
...will give a NullPointerException if "action" is null.
Am I right in assuming this?
Thanks for your help!
For example, if I have three conditionals ANDed together and the first one is false, then are the other two tested?
The reason I ask is I have a multiple OR conditional and one of the conditions might result in a NullPointerException if it is executed. I do have a test for nulls earlier in the expression.
My assumption is that:
Code:
if (action == null || (action.indexOf("string") > -1))
Code:
if ((action.indexOf("string") > -1) || action == null)
Am I right in assuming this?
Thanks for your help!