Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Method Overloading by changing the data type of parameters Java

class MethodOverloading {

    // this method accepts int
    private static void display(int a){
        System.out.println("Got Integer data.");
    }

    // this method  accepts String object
    private static void display(String a){
        System.out.println("Got String object.");
    }

    public static void main(String[] args) {
        display(1);
        display("Hello");
    }
}
 
PREVIOUS NEXT
Tagged: #Method #Overloading #changing #data #type #parameters #Java
ADD COMMENT
Topic
Name
5+9 =