Is there a better way to negate a boolean in Java than a simple if-else?
if (theBoolean) { theBoolean = false; } else { theBoolean = true; } <
if (theBoolean) { theBoolean = false; } else { theBoolean = true; }
theBoolean ^= true;
Fewer keystrokes if your variable is longer than four letters
Edit: code tends to return useful results when used as Google search terms. The code above doesn't. For those who need it, it's bitwise XOR as described here.