Can somebody tell me why the value returned is 3 and not 8. Doesn\'t the return x
statement from the addFive
method change the value of x
when you call a method in java and you don't assign for any variable, the changes will happen in the method call, after that this value will be lost and go back to the value that you assign. to see the result you should do that System.out.println(addFive(x));
but if you want to change the value of x
you have to assign x = addFive(x);