addFive(int x ). x addFive(int x).
The JVM creates a copy of x and sends it to the method addFive(int x). Then xchanges in the method addFive(int x). But the xin method main()remains unchanged.
If you want to get the modified value returned addFive(int x)from the main method, you can do the following -
int returnedValueFromAddFive = addFive(x)
Hope this helps.
Many thanks.
source
share