I'm trying to learn Java basics in an app, and while i've been doing fine understanding how the arithmetic itself works this code example they provided confused me a bit.
int x = 10
int y = x - 5; // y will equal 5
y = x / 4; // y will equal 2
y = x * 4; //y will equal 8
y = x % 3; // y will equal 1
My question is if int y = x - 5 is equal to 5, shouldnt the next declaration be 5/4 = 1.25 which is 1 instead of 10/4 = 2? Why does x still apply to the first line of y without the int declaration but the next two use the previous answer of y? This question is worded a bit weird, sorry about that.
"Why is it y = 10 / 4 instead of y = 5 / 4"