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
in the main
method?
public class App {
public static void main(String[] args) {
int x=3;
addFive(x);
System.out.println("x = " + x);
}
private static int addFive(int x) {
x += 5;
return x;
}
}