Parameters are copies
When a method is called, each parameter gets a copy of the argument's value. The method can change its parameter, but that changes only its own copy:
public class Main {
public static void main(String[] args) {
int score = 10;
doubleIt(score);
System.out.println("In main: " + score);
}
public static void doubleIt(int score) {
score = score * 2;
System.out.println("In the method: " + score);
}
}
In the method: 20
In main: 10Both variables are called score, but they're two different variables: each method has its own. The name used in the call doesn't matter either. Only the value is passed on, so doubleIt(score), doubleIt(10) and doubleIt(5 + 5) all do the same.
To get a value back out of a method, the method has to return it. That's the next module. (For objects, such as lists, there's more to the story; the module on primitive and reference variables tells it.)