Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Parameters allow us to customize the behavior of a subroutine to adapt it to a particular situation.

Information can
be passed to methods as parameter. Parameters are specified after the method name, inside the parentheses. You
can add as many parameters as you want, just separate them with a comma. There are two types of parameters, the
formal parameter and the actual parameter.

The difference between formal and actual parameters:


Formal parameter: the identifier used in a method to stand for the value that is passed into the method by a caller.

Actual parameter: the actual value that is passed into the method by a caller. The parameters that are passed while
calling or invoking the method are known as actual parameters.

Example of formal parameter and actual parameter:


public class multiply {

public static int multiplication (int num1, int num2) // here the variables num1 and num2 are formal parameter.
{
int product = num1*num2;
System.out.println("the product is "+product);
return product;
}
public static void main(String [ ] args){
multiplication(56,87); // here 56 and 87 are actual parameter.
}
}
Formal parameters are the variables or objects that are defined in the function/method signature, whereas
actual parameters are the variables that are sent when calling a function/method.

You might also like