/*
Parameters are used to pass data to the method.
This allows to call same method with different values of data.
Actual parameters - variables or values passed to the method while calling.
Formal parameters - variables declared in method signature (between parentheses).
*/
class Main {
public static void main(String[] args) {
int v = 1;
// here, variable 'v' and value '2' are Actual parameters
int result = sum(v, 2);
System.out.println(result);
}
public static int sum(int a, int b) {
// here, variables 'a' and 'b' are Formal parameters
return a + b;
}
}
Comments
Leave a comment