java - What does the = operator do when used twice on three integers? -


this question has answer here:

what do?

int x = 1; int y = 2; int z = 3; x = y = z; 

i have come across multiple of type of thing in few open source projects , have been confused them. them mean = operator being used twice on 3 integers i.e. x = y = z;. need understand this. thanks!

the operator = evaluates right hand side , assigns result variable on left hand side. expression returns value.

for work, evaluation proceeds right left:

x = (y = z); 

y becomes 3 , value returned 3. thus, x assigned 3 well.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -