Card 03/ 10
All 10 cards
ConceptDifficulty: Beginner1 min
Parameters Are Names; Arguments Are Values
Two words that get used as though they meant the same thing, until an error message uses one of them precisely and it stops making sense.
double vatOn(double amount) {
return amount * 0.20;
}
double tax = vatOn(19.99);| Word | Where it lives | In the listing |
|---|---|---|
| Parameter | In the declaration | amount — a name with a type, and nothing in it yet |
| Argument | At the call | 19.99 — an actual value, handed over |
A parameter is a local variable that the method declares and the caller fills in. It exists only while the method runs, and its name is invisible to callers — renaming amount to net changes nothing outside the body.
The order matters and the names do not. transfer(from, to) and transfer(to, from) compile identically when both are the same type, which is why a method with three parameters of one type is a method waiting to be called wrongly.
Holding the distinction is what makes an error like "incompatible types: String cannot be converted to int" readable — it is telling you which argument failed to fit which parameter.