Method Overloading
public class Overloading {
/* Function overloading is the re definition of a function with same name but
difference in number of arguments or type of arguments or return type. */
public void display(){
System.out.println("Inside display without any parameters");
}
public void display(int a){
System.out.println("Inside display accepting integer parameter "+a);
}
public void display(String a){
System.out.println("Inside display accepting String parameter "+a);
}
public static void main(String[] args) {
Overloading over=new Overloading();
over.display();
over.display(100);
over.display("HELLO WORLD..!!");
}
}
Output:
Inside display without any parameters
Inside display accepting integer parameter 100
Inside display accepting String parameter HELLO WORLD..!!