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 answers

i 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 invert b. then assign b.

the assignment operator returns assigned value. therefore, (b =! b) evaluates true - print out.

java syntax

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -