Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java Overloading by changing the number of parameters

class MethodOverloading {
    private static void display(int a){
        System.out.println("Arguments: " + a);
    }

    private static void display(int a, int b){
        System.out.println("Arguments: " + a + " and " + b);
    }

    public static void main(String[] args) {
        display(1);
        display(1, 4);
    }
}
 
PREVIOUS NEXT
Tagged: #Java #Overloading #changing #number #parameters
ADD COMMENT
Topic
Name
5+8 =