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
The method does return a value, but you have to set the value to a variable too when you return it, or else how would it know which variable you want to return the value to? You can have 10 variable, and if you just call the method, how will it know which variable to return the number to? That's why you have to set the returning number it to a variable like this:
x = addFive(x);