April 8, 20178 yr 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.
April 10, 20178 yr Author 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
Create an account or sign in to comment