I am trying to solve this "incrementation" problem in a Java code but I can't find myself arriving at a solution:
public class Return {
public static void main(String[] args) {
int n = returnn(3);
System.out.println(n);
}
public static int returnn(int n) {
return n++;
}
}
I am supposed to return 4 but it is returning 3 instead. Why is that? Also, when I type:
return n+=1
it works. This is confusing me. Also, what is the difference between n++
and ++n
? Any clarification is greatly appreciated.