Hello! I just did some thinking. Did you see what error your failed tests returned? You're right in the sense that (a && b) == (b && a) when it comes to truthfulness. However, by not checking for null first, you're opening yourself up to a NullPointerException, as 'null' isnt treated as equivalent to 'false' by the compiler.
When you do a null check first, you prevent this from happening. The compiler reads from up-down, left-to-right, so if your AND statement fails in the first condition, the second condition will never evaluate, as the statement is already false. Consider it a compiler optimization. I mainly did it to save LOC, instead of having a separate if statement for the null check.
please see my revised comment. if youre reading this in your email, you may not see my edit.
Hello! I just did some thinking. Did you see what error your failed tests returned? You're right in the sense that (a && b) == (b && a) when it comes to truthfulness. However, by not checking for null first, you're opening yourself up to a NullPointerException, as 'null' isnt treated as equivalent to 'false' by the compiler.
When you do a null check first, you prevent this from happening. The compiler reads from up-down, left-to-right, so if your AND statement fails in the first condition, the second condition will never evaluate, as the statement is already false. Consider it a compiler optimization. I mainly did it to save LOC, instead of having a separate if statement for the null check.
Best of luck in your learning!