Final Posted April 8, 2017 Posted April 8, 2017 1 hour ago, toomaz109 said: public class MyClass { public static void main (String[] args) { int x = 5; addOneTo(x); System.out.println(x); } static void addOneTo (int num) { //You have to pre increment to see the result after referencing x ++num; } } That isn't the issue which is occuring.
obasan Posted April 10, 2017 Author Posted April 10, 2017 On 4/8/2017 at 2:22 PM, toomaz109 said: public class MyClass { public static void main (String[] args) { int x = 5; addOneTo(x); System.out.println(x); } static void addOneTo (int num) { //You have to pre increment to see the result after referencing x ++num; } } naw niga java passes by value, not reference. u can add a billion to num, but its still gonna output 5