In Java, overloading provides the ability to define two or more methods with the same name. What is the use of that? For example, you want to define two methods, in which, one method adds two integers and the second method adds two floating point numbers. If there is no overloading, we have to create two different methods. One for adding two integers and the other for adding two floating point numbers. As the underlying purpose of the methods is same, why create methods with different name? Instead of creating two different methods, overloading allows us to define two methods
The post Why do we need method overloading in Java appeared first on Coding Security.
Why do we need method overloading in Java
read more
Tidak ada komentar:
Posting Komentar