What Is The Difference Between Parameters and Argument in Java?

0
42
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

image credit:www.python-course.eu

A method uses parameter but a calling method passes argument. So arguments are those which are passed to methods.Parameters are those values which try to catch the arguments sent by the caller/calling methods and assign it to a local variable.

A parameter is a part of method signature whereas the arguments are expressions used to call a method.

The argument sent by the calling method goes and sit exactly the same order in the parameter list.

Arguments can be of variable type
Exp:

int val=add(3,5);
int val=add(a,b);
//here we are passing arguments to the method add.

public int add(int a,int b)
// int a,int b are parameters for this method
{
return a+b;
}

By this way the values can be passed to called method.This is called pass by value.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

LEAVE A REPLY

Please enter your comment!
Please enter your name here