A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Method overloading in Java:

Method overloading in Java?

Method overloading in Java: Concept Behind

When a class contains multiple methods with the same name and with different parameters is known as Method overloading. If we have to perform only one operation in the program, having the same name as the methods increase the readability of the program.
Consider if we have to perform addition of the given numbers but there can be any number of arguments. If you use two parameters in a method such as
MethodName(int int){} if you want to use three parameters in a method such as
MethodnNme2(int, int, int){}.

Now, it may be difficult to understand the behaviour of the method for you as well as other programmers, because its name differs. That’s why we use method overloading to figure out the program quickly. Advantage of method overloading: It increases the readability of the program.

Different ways to overload the method

There are two ways to overload the method in java:-

1. By changing the number of arguments
2. By changing the data type