Final Posted April 8, 2017 Share 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. Quote Link to comment Share on other sites More sharing options...
obasan Posted April 10, 2017 Author Share 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 Quote Link to comment Share on other sites More sharing options...