Method Overloading
TLDR: Method overloading is a programming feature that allows multiple methods in the same class to have the same name but differ in their parameter lists, such as the number, type, or order of arguments. Supported in languages like Java, CPP, and Python (via default arguments), method overloading improves code readability and reusability by enabling the use of a consistent name for related operations.
https://en.wikipedia.org/wiki/Function_overloading
In Java, method overloading is achieved by defining multiple methods with the same name but distinct parameter signatures. For example, a method named `calculate` can have overloaded versions like `calculate(int a, int b)` and `calculate(double x, double y, double z)`. The Java compiler selects the appropriate method to invoke based on the arguments provided. However, overloaded methods must differ in their parameter lists, as method return types alone cannot distinguish them.
https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
Method overloading is commonly used in constructors, where multiple constructors allow objects to be initialized in different ways. For example, a `Person` class may have overloaded constructors for initializing with either a name or both a name and age. While powerful, method overloading should be implemented with caution to avoid confusion, ensuring that each method's purpose is clear and consistent within the class.
https://docs.oracle.com/javase/specs/jls/se20/html/jls-8.html