- 1

how create overload method in java?

two method with same name but different parameters

26th Feb 2020, 1:13 AM
Abdulkedir Dube
Abdulkedir Dube - avatar
2 Réponses
+ 4
Hello Abdulkedir Dube You can have a look into my code: https://code.sololearn.com/cggcHjdL0HEE/?ref=app You can ask me if you need more explanation :)
26th Feb 2020, 1:15 AM
Denise Roßberg
Denise Roßberg - avatar
+ 4
Overloading is the way to use same method name instead of having different names for different operations.For example in Java you have a method called abs() that you can pass different datatypes you need Like Math.abs(-15);// 15 Math.abs(-15.0);// 15.0 Unlikely in c you need to create different functions for different operations. In c you need abs() for int and fabs() for floating points decimals. This will make the code harder to maintain.So Java comes with feature called overloading.Tahat can achieve by different ways like Using different types of parameters,using parameters or no parameter, parameters placings etc.
26th Feb 2020, 4:42 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar