Tuesday, 29 August 2017

java programming tutorial to use of Method Overloading in java

Create a class Demo and show the use of Method Overloading

Program

class Addition{
          void add(int i1,int i2){
                   System.out.println("Addition of Integers is"+(i1+i2));
          }
          void add(double d1,double d2){
                   System.out.println("Addition of Doubles is"+(d1+d2));
          }
}

class Demo{
          public static void main(String []args){
                   Addition ad = new Addition();

                   ad.add(20,40);        ad.add(20.40,80.90);       }      }

Output

Method Overloading Core Java

0 comments:

Post a Comment