Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


7,904 questions

11,012 answers

573 users

How to use method overloading in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
    
    public static double GetArea(int x,int y) {
        return x * y;
    }
    public static double GetArea(int x) {
        return x * x;
    }
    public static double GetArea(int x,double y) {
        return x * y;
    }
    public static double GetArea(double x) {
        return x * x;
    }
    public static void main(String[] args) {
        System.out.println(GetArea(3, 6));
        System.out.println(GetArea(5, 4.7));
        System.out.println(GetArea(8));
        System.out.println(GetArea(3.14));
    }
}


/*
run:

18.0
23.5
64.0
9.8596

*/

 




answered Jul 4, 2017 by avibootz
...