What is a method and what are they used for:
A method is a sequence of program statements that have a specific task that they perform.
Methods can be used to define reusable code, organize and simplify coding, and make code easier to maintain.
Creating a method involves writing the statements and providing a method declaration with:
Defining a method syntax:
modifier returnValueType methodName(list of parameters){
//method body
return returnValue;
}
Calling (or invoking) a method involves
Syntax:
variable = methodName(list of arguments);
A method is a:
A method is a collection of statements that are grouped together to perform an operation
Method signature
Refers to the combination of the method name and the parameter list
Formal parameters
The variables defined in the method header are known as the formal parameters
Actual parameters
When a method is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument.
x,y in int z = max (x, y);
Return Type Value 14