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