Method Overloading in java

preview_player
Показать описание
If a class has multiple methods having same name but different in parameters, it is known as Method Overloading.

If we have to perform only one operation, having same name of the methods increases the readability of the program.

//Method overloading in java.
package OOPs;
public class OOPs_07 {
static int add(int a, int b){ //method.
return a + b;
}
static int add(int a, int b, int c){ //method overloading
return a + b + c;
}
public static void main(String[] args) {
}
}
Рекомендации по теме