Overloading Method / Function

PHOTO EMBED

Mon Apr 19 2021 23:07:00 GMT+0000 (Coordinated Universal Time)

Saved by @ahmedqgqgq #java

public class MyName {
    static int sum(int n1, int n2) {
        return n1 + n2;
    }
    public static void main(String[] args) {
        System.out.println("Sum==" + sum(10, 50));
    }
}
public class MyName {
    static int sum(int n1, int n2) {
        return n1 + n2;
    }
    static float sum(float n1, float n2) {
        return n1 + n2;
    }
    public static void main(String[] args) {
        System.out.println("Sum==" + sum(10, 50));
        System.out.println("Sum==" + sum(10.5f, 50.7f));
    }
}
public class MyName {
    static int sum(int n1, int n2) {
        return n1 + n2;
    }
    static float sum(float n1, float n2) {
        return n1 + n2;
    }
    static float sum(int n1, float n2) {
        return n1 + n2;
    }
    public static void main(String[] args) {
        System.out.println("Sum==" + sum(10, 50));
        System.out.println("Sum==" + sum(10.5f, 50.7f));
        System.out.println("Sum==" + sum(10, 10.5f));
    }
}
public class MyName {
    static float order(float total) {
        return total;
    }
    static float order(float total, int deliverycosts) {
        return total + deliverycosts;
    }
    static float order(float total, int deliverycosts, String promo) {
        return total + deliverycosts - 2;
    }
    public static void main(String[] args) {
        System.out.println(order(15, 3, "Ahmed"));
    }
}
public class MyName {
    static void fun() {
        System.out.println("fun:");
    }
    static void fun(int x) {
        fun();
        System.out.println("x==" + x);
    }
    public static void main(String[] args) {
        fun(15);
    }
}
public class MyName {
    public static void main(int num) {
        System.out.println(num);
    }

    public static void main(String[] args) {
        main(500);
    }
}



content_copyCOPY