Method overloading: How to overload a method in Java?

You can overload methods (define two or more methods with same names in a class) in Java. However, the methods should be having different return types or different parameters. This process is known as method overloading. Method overloading is one of the features of Java which shows polymorphism.

For Example:

class Myclass {

void met() {

System.out.println(“Method with no parameters”);


void met(int x) {

System.out.println(“x: ” + x);

double met(double x) {

System.out.println(“double x: ” + x);

return x*x;




Leave a Reply