+ 1

public class Program { public static void main(String[] args) { int x = 34; int y = ++x; int z = x+y

while output is 70? not 69?

30th Oct 2019, 9:09 PM
Daniel
Daniel - avatar
4 odpowiedzi
+ 2
Daniel you probably figured this out already, the below is just a breakdown for newbies scrolling through 😊 int x = 34 >> x = 34 int y = ++x >> x = 34 + 1 >> x = 35 >> y = 35 int z = x + y >> z = 35 + 35 >> z = 70
30th Oct 2019, 9:22 PM
will
will - avatar
+ 1
becaus ++x means increase the value of x by one AND THEN put it in y
30th Oct 2019, 9:12 PM
George Samanlian
+ 1
yes, of course. i have already guessed:) Thank you
30th Oct 2019, 9:14 PM
Daniel
Daniel - avatar
+ 1
Daniel got it =70
31st Oct 2019, 2:02 AM
Filipe Ferreira
Filipe Ferreira - avatar