Conditional statement true in both parts of if-else-if ladder
问题 If you have code like this: if (A > X && B > Y) { Action1(); } else if(A > X || B > Y) { Action2(); } With A > X and B > Y , will both parts of the if-else-if ladder be executed? I'm dealing with Java code where this is present. I normally work in C++, but am an extremely new (and sporadic) programmer in both languages. 回答1: No, they won't both execute. It goes in order of how you've written them, and logically this makes sense; Even though the second one reads 'else if', you can still think