Reputation: 311
Does Java 8 have a post unary operator for primitive booleans?
int a = 1;
a++; //look at then increment
boolean bool = true;
???
Upvotes: 1
Views: 150
Reputation: 140319
No, there is no such operator.
Even the !
isn't doing the same as ++
does with numeric types:
++
updates a variable (or array element); !
negates the value of an expression. If applied to a variable, the variable's value is unchanged.The most similar thing to a "negate operator" would be
(aBoolean ^= true)
but this is "pre-negate", rather than "post-negate".
You can contrive a "post-negate operator" using non-short circuiting operators:
(aBoolean | ((aBoolean ^= true) & false)
But really: don't do this. It's baffling.
Upvotes: 1