2.11 Method Overloading
Introduction
Method overloading lets a class define multiple methods with the same name, as long as their parameter lists differ (in number, type, or order). The compiler picks the correct overload to call based on the arguments provided at the call site — this is resolved at compile time, not runtime.
Key Concepts
Java Syntax
Code Examples
Three `add` overloads share a name but differ in parameter count/type. Java selects the matching overload for each call based on the arguments' types.