Method Overloading Example in Java

By | December 17, 2010
Method Overloading Example in Java. You can find method overloading in Java Program (code snippets) in this page.

Method Overloading Example in Java. You can find method overloading in Java Program (code snippets) in this page.

class MethodOverloading{

public void display(int num){

System.out.println(“\n\tInteger value: ” + num);

}

public void display(float value){

System.out.println(“\n\tFloat value: ” + value);

}

public void display(char ch){

System.out.println(“\n\tCharacter value: ” + ch);

}

}

public class MethodOverloadingDemo{

public static void main(String args[]){

MethodOverloading ob = new MethodOverloading();

ob.display(123);

ob.display(1.11f);

ob.display(‘A’);

}

}

Result:

Integer value: 123

Float value: 1.11

Character value: A

Leave a Reply

Your email address will not be published. Required fields are marked *