+ 2
What is methodoverloading
dontknow
2 Antworten
+ 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.
0
it's the process of writing several methods with the same name provided that their arguments types and numbers aren't the same.