+ 1

why is this true?

int x=1; System.out.print(++x==x);

5th Nov 2019, 11:30 PM
Amir allameh
Amir allameh - avatar
5 ответов
+ 8
because ++x increases x to 2, and after that, x will still be == x (2==2).
5th Nov 2019, 11:49 PM
HonFu
HonFu - avatar
+ 6
we know the precidence of ( ++) operator is highest priority then (==) operator so first increment the value of x that is why in memory location x became 2 and then (==) operator execute (2==2) that is true
6th Nov 2019, 2:45 AM
Saroj Patel
Saroj Patel - avatar
+ 3
tnx
5th Nov 2019, 11:54 PM
Amir allameh
Amir allameh - avatar
+ 1
(2==2)
5th Nov 2019, 11:51 PM
Weltix
Weltix - avatar
0
2==2
7th Nov 2019, 11:12 PM
Marco Ascia
Marco Ascia - avatar