+ 2

What is methodoverloading

dontknow

11th Mar 2017, 6:52 AM
sabera
sabera - avatar
2 Respostas
+ 2
When methods have SAME NAME ,but DIFFERENT PARAMETERS. Uses:- Lets have a look at this java program. public class A{ public static void add(int a, int b){ System.out.print(a+b); } public static void add(double a ,double b){ System.out.print(a+b); } public static void main(String[] args){ add(6,7);//outputs 13 add (6.3,7.3);//outputs 13.6 }} As you can see for add integers, first add method is called , and for adding doubles second method is called. Hence add method is overloaded to work with either int or double.
11th Mar 2017, 6:57 AM
Meharban Singh
Meharban Singh - avatar
0
it's the process of writing several methods with the same name provided that their arguments types and numbers aren't the same.
11th Mar 2017, 6:57 AM
Aboubacar Traore
Aboubacar Traore - avatar