KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
So for binary operators on booleans, Java has & , | , ^ , && and || . Let's summarize what they do briefly here: JLS 15.22.2 Boolean Logical Operators &, ^, and | JLS 15.23 Conditional-And Operator && JLS 15.24 Conditional-Or Operator || For & , the result value is true if both operand values are true ; otherwise, the result is false . For | , the result value is false if both operand values are false ; otherwise, the result is true . For ^ , the result value is true if the operand values are different; otherwise, the result is false . The && operator is like & but evaluates its right-hand operand only if the value of its left-hand operand is true . The || operator is like | , but evaluates its right-hand operand only if the value of its left-hand operand is false . Now, among all 5, 3 of those have compound assignment versions, namely |= , &= and ^= . So my question is obvious: why doesn't Java provide &&= and ||= as well? I find that I need those more than I need &= and |= . And I don't think that "because it's too long" is a good answer, because Java has >>>= . There
Tags (comma-separated)
Save Edits
Cancel