Why am I getting an output equals 5? I was expecting 6, because after the "addthenumber(x);" line, the method is called, and what I am thinking is the method performs the calculation and 5 becomes 6. So sysout should print 6, but how is it 5?
public class CodeMomkeyPassingvalue
{
public static void main(String[] args)
{
int x = 5;
addthenumber(x);
System.out.println(x);
}
private static void addthenumber(int number)
{
number = number+1;
}
}
output:
5