I'm learning the Java language and am trying to do this:
public class IntegerPlusOne {
public static int addOne(int n) {
n = n + 1;
return n;
}
public static void main(String[] args) {
int n = 0;
addOne(n);
System.out.println(n);
}
}
It should be printing "1", but instead it print zero. No matter what I set n equal to, the addOne function never changes it and I think the function is broke, but if I test it on its own it returns one more than whatever int I send to it which really confuses me.