Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Operator precedence in Java with assignment [duplicate]

$
0
0

Can anyone help me understand the logic behind the following results?

Case 1.

int x,a = 100;x = a + (a=6);System.out.println(x);  //prints 106

Case 2.

int x,a =100;x = (a=6) + a;System.out.println(x);  //prints 12

why a=6 not evaluate first in 1st case


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>