Methods are necessary for manipulating the data contained in the class. Methods are declared inside the body of the class but immediately after the declaration of instance variables. The general form of a method declaration is
            Type methodname (parameter-list)
            {
                        method body;
            }
Method declarations have four basic parts:

  • The name of the method(methodname)
  • The type of the value the method returns(type)
  • A list of parameters(parameter-list)
  • The body of the method
The type specifies the type of value the method would return. This could be a simple data type such as int as well as any class type. It could even be void type, if the method does not return any value. The methodname is a valid identifier. The parameter list is always enclosed in parantheses.This list contains variable names and types of all the values which is to be given as the input to the method.