Formal and Actual Parameters in Java
Below is the implementation of Formal and Actual Parameters in Java:
/*package whatever //do not write package name here */
import java.io.*;
class GFG {
// a and b are formal parameters
static int sumNumbers(int a, int b) { return a + b; }
public static void main(String[] args)
{
// 3 and 5 are actual parameters
int result = sumNumbers(3, 5);
System.out.println("Sum: " + result);
}
}
Output
Sum: 8
Formal and Actual Parameters in Programming
In programming, parameters are variables or values passed to a function or method during its invocation. They enable the function to receive input data, perform operations, and optionally return a result.