+ 3
Method overloading
What is the advantage of method overloading ?
4 odpowiedzi
+ 3
Tom is right, in addition I would say "you can also call the same method using different number of parameters".
+ 4
The main advantage is the flexibility to use a similar method with different types of values.
+ 3
The method could then accepts more than one type of arguments. For example, you wrote a method called: add(a, b) => if you overload the method (wrote several different methods with the same name) to accept types of Integer, Double and String. Your method now is capable of receiving input as integer, double, String and behave differently with each type of input.