A method needs to be defined before it is used. A method consists of two parts: header part and body part. The method header is the first line of the function declaration or definition whereas the method body contains a set of statements for related operations written in curly brackets. Modifier tells the compiler how to call the method. Return type specifies the type of value returned from a function. Function name is the name assigned to the method. Parameter list is comma-separated list of variables of a function.
The methods 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 programmers as per their need. A function exists in three different forms within a program: method prototype, method definition and method call. Function prototype is the first line of the method definition ended by semicolon that tells the program about the signatures of the function. Defining a method 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. The data type void specifies empty set of values and it is used as the return type.