Java Method Overloading Example


Program
class Addition{ static int arg(int a,int b){return a+b;} static double arg(double a,double b){return a+b;} static int arg(int a,int b,int c){return a+b+c;} } public class methodoverloading{ public static void main(String[] args){ Addition a=new Addition(); System.out.println(a.arg(1,7)); System.out.println(a.arg(1.0,9.0)); System.out.println(a.arg(1,7,8)); }}
Input
Output