0

Why? ( ‘-ωก̀ )

public class MyClass { public static void main(String[ ] args) { int x = 5; addOneTo(x); System.out.println(x); } static void addOneTo(int num) { num = num + 1; } } Why is "5"?

16th May 2017, 1:47 PM
Michael Wu
Michael Wu - avatar
1 Réponse
+ 1
because you're only changing the internal variable of the function addOneTo(int num) that means num, but x remains how it has been
16th May 2017, 1:49 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar