NEWS: Total Picture Views: 151536 | Total Article Views: 161006 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. PickUpThings with Becker Robot | 3. How to read a JSON and work with it | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

Overload Method Java

Description:

In this example I will be showing Overload method. Overload method is the same method name but with different paramter.

Code:

public class Main {

    public static void main(String[] args) {

        //Overload method mean that you have a method with the same name but different parameter.
        //overload is the name I choose for the example but you can choose the name you want.
        overload(1,1);
        overload(5,"David");
        overload(1.5,1.75);
    }

    public static void overload(int x, int y){
        System.out.println("The answer of " + x + " + " + y + " = " + (x + y));
    }

    public static void overload(int x, String y){
        System.out.println( y + " is " + x + "years old");
    }

    public static void overload(double x, double y){
        System.out.println("The answer of " + x + " + " + y + " = " + (x + y));
    }

}
Attachments: None

Tags: Overload Overload Method Method

Total Views: 917

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 09/04/14


affiliate_link

Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.