Java logical operator (&&, ||) short-circuit mechanism
问题 As I was reading a colleague's Java code, I stumbled upon an army of if/else statements. In these statements, several && and || operators were fighting each other without any help from parenthesis. I simplified the statements into: if (true || true && false) return true; else return false; What do you think the result would be? Honestly, I thought it would be false , but it seems short-circuiting doesn't work like I expected. In this case, the result is true . The short-circuit mechanism