Possible Duplicate:
What's the difference between an argument and a parameter?
I was going through some interview questions. I wasn't able to come up with a solid answer to this question:
Difference between arguments and parameters in Java?
How are they different?
The values that are declared within a function when the function is called are known as an argument. The variables that are defined when the function is declared are known as parameters. These are used in function call statements to send value from the calling function to the receiving function.
A java argument is a value passed to a function when the function is called. Whenever any function is called during the execution of the program there are some values passed with the function.
When a function is called, the values (expressions) that are passed in the function call are called the arguments or actual parameters. The parameter used in function definition statement which contain data type on its time of declaration is called formal parameter.
Generally a parameter is what appears in the definition of the method. An argument is the instance passed to the method during runtime.
You can see a description here: http://en.wikipedia.org/wiki/Parameter_(computer_programming)#Parameters_and_arguments
The term parameter refers to any declaration within the parentheses following the method/function name in a method/function declaration or definition; the term argument refers to any expression within the parentheses of a method/function call. i.e.
Please have a look at the below example for better understanding:
package com.stackoverflow.works; public class ArithmeticOperations { public static int add(int x, int y) { //x, y are parameters here return x + y; } public static void main(String[] args) { int x = 10; int y = 20; int sum = add(x, y); //x, y are arguments here System.out.println("SUM IS: " +sum); } }
Thank you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With