+ 1

Why this output still 0?

class A{ public static void main(String [] args) { int x =0; addOneTo(x); System.out.println(x); } static int addOneTo(int I){ I = I + 1; return I; } }

12th Jul 2018, 4:27 AM
Afresia
Afresia - avatar
3 Respuestas
+ 3
Afresia two things. You defined a method on after the call. You did not return the value x after you called it. x = addOne(x); https://code.sololearn.com/cGtLWy91tmVn/?ref=app
12th Jul 2018, 4:40 AM
Manual
Manual - avatar
+ 3
Afresia You're Welcome!
12th Jul 2018, 4:48 AM
Manual
Manual - avatar
+ 2
ooo, I got it, thank you Manual
12th Jul 2018, 4:45 AM
Afresia
Afresia - avatar