+ 3

Please explain this to me!

I need somebodies help to understand this: int x=4; int y= ++×*4/×+×; system.out.println(x+y); //Outcome is 14 but I dont get how. I appreciate any support. I got it wrong in a challange and I want to know how to solve it properly.

19th Sep 2017, 12:39 PM
Ryan C
Ryan C - avatar
8 Answers
+ 7
Tricky part is paying attention to your order of operations since you aren't using parenthesis. Other than that, just simple math. Don't forget that ++x increments the value before its operation. x: 4 y = ++x*4 = 20 X: 5 y = 20 / 5 = 4 y = 4 + 5 = 9 x + y = 14
19th Sep 2017, 1:16 PM
AgentSmith
+ 6
what you dont understand?
19th Sep 2017, 12:41 PM
Amethyst Animion
Amethyst Animion - avatar
+ 4
lolol You're absolutely right Gordie. It's early still and I'm lacking my cup of coffee. Thanks for correcting me.
19th Sep 2017, 1:15 PM
AgentSmith
+ 3
lol Will do. The sad part is that I told him not to forget, and my dumb ass forgot immediately after I said that. I'm not sure if coffee can fix stupid. :D
19th Sep 2017, 1:19 PM
AgentSmith
+ 1
sry I had to edit the post
19th Sep 2017, 12:43 PM
Ryan C
Ryan C - avatar
0
Thank you guys, rookie mistake I did after all. Good to know to have some quick responders being part of this community.
19th Sep 2017, 4:40 PM
Ryan C
Ryan C - avatar