JavaWhat is Method Overloading?
// Method overloading allows multiple methods in the same class to have the same name with different parameters.
public class Main {
void display(int a) {
System.out.println("Integer: " + a);
}
void display(String b) {
System.out.println("String: " + b);
}
public static void main(String[] args) {
Main obj = new Main();
obj.display(5); // Output: Integer: 5
obj.display("Hello"); // Output: String: Hello
}
}