Java, J2EE & SOA Certification Training
- 39k Enrolled Learners
- Live Class
Method Overloading in Java is a concept related to Object Oriented Programming (OOP). Java supports overloading of methods and can distinguish between different methods with method signatures. A situation, wherein, in the same class there are two or more methods with same name, having different functions or different parameters, it is called Method Overloading. To take an in depth look at what Method Overloading is to have a better understanding of this concept.
A method is a collection of statements that are grouped together to perform an operation. It takes some parameters, performs some computations, and then optionally returns a value (or object). To create a particular functionality, a method is needed to be created so as to modularize the application. By making a method, one can call that particular method at different instances. In this way, the code redundancy can be reduced and the code can be reused. There are five components in a method:
Now, that we have an idea of what a method is, let’s go back to Method Overloading that we defined in the beginning of this post – It is a situation, wherein, in the same class there are two or more methods with same name, having different functions or different parameters. Following are the conditions for method overloading in Java:
Method Overloading can be done in two ways:
Using Method Overloading in Java is very common among Java programmers, because it:
Got a question for us? Mention them in the comments section and we will get back to you.