syntax - What is the difference between != and =! in Java? -
syntax - What is the difference between != and =! in Java? -
this question has reply here:
what's =! operator? [duplicate] 13 answersi looking on mock ocjp questions. came across baffling syntax. here is:
class oddstuff { public static void main(string[] args) { boolean b = false; system.out.println((b != b));// false system.out.println((b =! b));// true } }
why output alter between !=
, =!
?
the question playing confusing spacing.
b != b
usual !=
(not equals) comparison.
on other hand:
b =! b
improve written b = !b
parsed as:
b = (!b)
thus it's 2 operators.
first invertb
. then assign b
. the assignment operator returns assigned value. therefore, (b =! b)
evaluates true - print out.
java syntax
Comments
Post a Comment