ProAnswers.org

What is Method in java?

Methods define actions that a class’s objects (or instances) can do.
A method has a declaration part and a body.
The declaration part consists of a return value, the method name, and a list of arguments.
The body contains code that perform the action.
The return type of a method can be a primitive, an object, or void.
The return type void means that the method returns nothing.
The declaration part of a method is also called the signature of the method.
For example, here is the getSalary method that returns a double.

public class MainClass {

double getSalary() {
return 0.0;

}
}