AP® Computer Science A glossary
Call by value
Also called: pass by value
Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods
The way Java passes arguments: each parameter is initialized with a copy of the argument.
Appears in the course and exam description (CED): 1.9.B.31.13.C.3
Because the parameter holds a copy, changing it inside the method does not change the caller’s variable. The copy disappears when the method ends.
public static void addTen(int value)
{
value = value + 10;
}
// in main
int score = 5;
addTen(score);
System.out.println(score);
Output:
5 Learn it properly, with a checkpoint 1.9 Method Signatures