When verbally talking about methods, I\'m never sure whether to use the word argument or parameter or something else. Either way the other people know what
When we create the method (function) in Java, the method like this..
data-type name of the method (data-type variable-name)
In the parenthesis, these are the parameters, and when we call the method (function) we pass the value of this parameter, which are called the arguments.
Parameters are variables that are used to store the data that's passed into a function for the function to use. Arguments are the actual data that's passed into a function when it is invoked:
// x and y are parameters in this function declaration
function add(x, y) {
// function body
var sum = x + y;
return sum; // return statement
}
// 1 and 2 are passed into the function as arguments
var sum = add(1, 2);
I thought it through and realized my previous answer was wrong. Here's a much better definition
{Imagine a carton of eggs: A pack of sausage links: And a maid } These represent elements of a Function needed for preparation called : (use any name: Lets say Cooking is the name of my function).
A Maid is a method .
( You must __call_ or ask this method to make breakfast)(The act of making breakfast is a Function called Cooking)_
Eggs and sausages are Parameters :
(because the number of eggs and the number of sausages you want to eat is __variable_ .)_
Your decision is an Argument :
It represents the __Value_ of the chosen number of eggs and/or sausages you are Cooking ._
{Mnemonic}
_" When you call the maid and ask her to make breakfast, she __argues_ with you about how many eggs and sausages you should eating. She's concerned about your cholesterol" __
( Arguments , then, are the values for the combination of Parameters you have declared and decided to pass to your Function )
A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method's parameters.
public void MyMethod(string myParam) { }
...
string myArg1 = "this is my argument";
myClass.MyMethod(myArg1);
Yes! Parameters and Arguments have different meanings, which can be easily explained as follows:
Function Parameters are the names listed in the function definition.
Function Arguments are the real values passed to (and received by) the function.
Generally speaking, the terms parameter and argument are used interchangeably to mean information that is passed into a function.
Yet, from a function's perspective: