+ 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; } }
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
+ 3
Afresia
You're Welcome!
+ 2
ooo, I got it, thank you Manual