Parameters
In short: The values passed to a method on a call — declared with type and name in the method header, filled with concrete values (“arguments”) at the call site.
In more detail: Java fundamentally passes parameters “by value”: for primitive types, a copy of the value is passed, for objects a copy of the reference — so field changes on the passed object do have an effect outside the method, but a complete reassignment of the parameter variable within the method does not.
In Depth
void doubleIt(int number) {
number = number * 2; // only changes the LOCAL copy, not the caller's original
}
int x = 5;
doubleIt(x);
System.out.println(x); // still 5 - unchanged!
void changeField(Car car) {
car.color = "Red"; // changes the FIELD of the object the reference points to
}
void assignNewObject(Car car) {
car = new Car("Blue"); // only changes the LOCAL copy of the reference variable
}
Car myCar = new Car("Green");
changeField(myCar);
System.out.println(myCar.color); // "Red" - the field change IS visible
assignNewObject(myCar);
System.out.println(myCar.color); // still "Red" - the reassignment was NOT visibleThis behaviour (“Java is always by value, never by reference”) is one of the subtlest points in the language and the source of many misunderstandings: for objects, a COPY of the reference is indeed passed — but both copies (original and parameter) point to the same object on the heap, which is why field changes remain visible. If, by contrast, you assign a completely NEW reference to the parameter (car = new Car(...)), that only affects the local copy of the variable within the method — the caller sees nothing of it, because its own variable still points to the original object.
Varargs: a variable number of parameters
Java allows methods with a variable number of parameters of the same type via varargs syntax (...) — internally this is treated as an array, but the caller syntax stays significantly more compact:
int sum(int... numbers) { // any number of int values, even none
int total = 0;
for (int n : numbers) total += n;
return total;
}
sum(); // 0 - valid, empty array
sum(1, 2, 3); // 6
sum(new int[]{4, 5}); // also works directly with an arrayA varargs parameter always has to be the LAST one in a method’s parameter list, and a method may have at most one single varargs parameter — otherwise the compiler wouldn’t unambiguously know where the variable list ends.
Parameter vs. argument
Strictly speaking, “parameter” refers to the variable declared in the method header (void method(int number) — number is the parameter), while “argument” refers to the concrete value at the call site (method(5) — 5 is the argument). In everyday usage, both terms are often used synonymously, but the distinction is common in technical literature and stack traces.
See also: Methods, Overloading, Arrays