The difference between parameters and arguments

The difference between parameters and arguments

The difference between parameters and arguments can sometimes be confusing.

Parameters are the variables that are part of a Method or Function’s signature. On the other hand, arguments are variables or real values you pass the function or method upon invocation.

Let us create see parameters in action

public class Account {
   public void openNew(int accountNumber, float newBalance) {
	// 
   }
}

The Account class defines a method openNew. The variables int accountNumber and float newBalance are parameters. They are variables that are part of the method’s signature.

Account account = new Account();
account.openNew(23984, 0.0);

In the sample code above, the openNew method is invoked passing two arguments, 23984 and 0.0.

Conclusion

We hope you have now understood the difference between parameters and arguments in programming. 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 parametersParameter is variable in the declaration of function. Argument is the actual value of this variable that gets passed to function.

For more java articles, visit simplecodegeeks.com/java

Share this article

About Michael Mulikita

Founder of Simplecodegeeks.com, I love programming and open source technologies. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

View all posts by Michael Mulikita →

Leave a Reply