what is argument in java

11 months ago 34
Nature

In Java, an argument is a value passed to a function when the function is called. Whenever a function is called during the execution of a program, there are some values passed with the function, which are called arguments. An argument, when passed with a function, replaces the variables used during the function definition, and the function is then executed with these values.

On the other hand, a parameter is a variable used to define a particular value during a function definition. Whenever a function is defined, some variables are introduced to the compiler, which are used in the running of that function. These variables are often called parameters. The parameters and arguments mostly have the same value but are theoretically different from each other.

In Java, arguments are the actual values that are passed to variables defined in the method header when the method is called from another method. The passed argument values replace those parameters that have been used during method definition, and the body of the method is then executed with these values.

It is important to note that Java uses pass-by-value, which means that when a method is called, a copy of each actual parameter (argument) is passed. You can change that copy inside the method, but this will have no effect on the actual parameter. Unlike many other languages, Java has no mechanism to change the value of an actual parameter.