Java Methods

Java Methods

A method describe the behavior of an object.
Methods define the operations that can be performed with the object.
The methods can be found only in the classes.

The methods consist of modifiers, declaring a name for the method, data type that the method returns, parameters and a block of instructions that are executed when the method is executed.

Modifiers can be:
Access specifier: public, protected, private.
One of the reserved keywords: static, abstract, final, native, synchronized.

Method example

public class MethodExample{  
  void m1(int x,int y){
  void m2(String name){
      System.out.println("Name: "+name);
  public static void main(String args[]){
      MethodExample ob = new MethodExample();