Java Method Overloading
Method overloading allows a class to have multiple methods with the same name, as long as their parameter lists are different (different number of parameters, different types, or different order of types). The compiler determines which method to call based on the arguments provided.
"Method overloading is like a "print" button on your printer: you can press it to print 1 page, or press it and specify 5 copies, or press it and specify color mode. Same button name ("print"), but with different parameters."
Deep Dive: How It Works
Overloading is determined by the method signature: name + parameter types.
Return type ALONE is not enough to overload a method. `int add(int a)` and `double add(int a)` will fail compilation.
Java's `System.out.println()` is the most famous example of method overloading: it has versions for int, double, boolean, String, char, and Object.
Syntax Blueprint
public static int add(int a, int b) { return a + b; }
public static double add(double a, double b) { return a + b; }Same method name "add", but different parameter types allow the compiler to distinguish them.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Changing only the return type: int add(int a) vs double add(int a)Why it happens: The compiler cannot determine which method to call if parameter signatures are identical.
How to fix: Ensure parameter types or count differ.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Overload a multiplier method
Write multiply(int a, int b) returning a * b.
Write multiply(int a, int b, int c) returning a * b * c.
In main, print "Result: " + multiply(2, 3, 4).
Finished reading and practicing?
Mark this lesson as completed to update your course progress.