Parameters
In short: Placeholder variables in the definition of a method or function, through which concrete values (“arguments”) are passed in on a call.
In more detail: A method can expect several parameters, each with a fixed type and name; via overloading, several variants of the same method can be defined with different parameter lists. Some languages distinguish between passing by value (a copy is passed) and by reference (a reference to the original) — for objects, usually the reference is passed, for simple values often a copy.
In Depth
An important, often overlooked distinction: parameters are the placeholder names in the method definition, arguments are the concrete values passed at the actual call.
// "amount" is the parameter (part of the definition)
void deposit(double amount) {
balance += amount;
}
account.deposit(100.0); // "100.0" is the argument (part of the call)The distinction between passing by value and by reference is one of the most common points of confusion for beginners:
void changeNumber(int number) {
number = 99; // only changes the LOCAL copy
}
void changeList(List<Integer> list) {
list.add(99); // changes the ORIGINAL list, because a reference was passed
}
int x = 5;
changeNumber(x);
System.out.println(x); // still 5 - primitive values are copied
List<Integer> l = new ArrayList<>();
changeList(l);
System.out.println(l); // now contains 99 - objects are passed by referencePrimitive values (numbers, booleans) are copied when passed — changes to the copy within the method do NOT affect the caller’s original variable. For objects (including arrays and collections), by contrast, only a reference is passed — both variables (the caller’s and the parameter’s within the method) point to the SAME underlying object, which is why changes to it remain visible even after the method ends.
Some languages additionally offer default values for parameters (if no argument is passed, a predefined value automatically applies) and named parameters (arguments are explicitly matched by name instead of position on a call) — both reduce the need for overloading, by allowing a single method to be called more flexibly with varying numbers of arguments.
See also: Methods, Overloading