Introduction to Function
Java statements are grouped together in methods (functions). A method must be defined before it is used in the program. Access specifier defines access control for the class elements inside the other classes according to their type specifiers. Modifier tells the compiler how to call the method. Return type specifies the type of value returned from a function. The void is used to specify that the function is not returning any value. Function name or method name is the name assigned to the method. Parameter list is the list of parameters. It is the type, order and number of parameters of a method.
The methods in Java are of two types – built in method and user-defined method. The built-in methods are pre-defined methods stored in the Java library. The user-defined methods are defined by the programmer as per their need. A method exists in three different forms within a program: method prototype, method definition and method call. A method prototype describes the method interface to the compiler by giving details such as the number and type of arguments. Method definition includes the method body containing statements to perform the task. A method is called (invoked or executed) by providing the method name along with the argument list enclosed in the parenthesis.