Arguments or parameters?

Viewed 28736

I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world.

What's the correct convention for their use?

12 Answers

Parameters are the things defined by functions as input, arguments are the things passed as parameters.

void foo(int bar) { ... }

foo(baz);

In this example, bar is a parameter for foo. baz is an argument passed to foo.

A Parameter is a variable in the declaration of a function:

functionName(parameter) {
    // do something
}


An Argument is the actual value of this variable that gets passed to the function:

functionName(argument);

Arguments are what you have when you're invoking a subroutine. Parameters are what you are accessing inside the subroutine.

argle(foo, bar);

foo and bar are arguments.

public static void main(final String[] args) {
    args.length;
}

args is a parameter.

Although Wikipedia is hardly an authoritative source, it does a decent job of explaining the terms.

I guess you could say that parameters are to arguments what classes are to instances of objects...

Related