Method with parameters

Parameters are the input values for the method enclosed in (), provided in the method call as arguments. Multiple parameters are separated by , and each parameter must have a data type.

static void showSum(int a, int b)
 System.out.print(a + b);

The following method receives two int parameters and displays their sum:

showSum(5, 10);

Get hands-on with 1200+ tech skills courses.