METHOD OVERLOADING IN JAVA
Method overloading means methods have the same name but different parameter list and different data types
Example:
class Addition
{
static int add(int a,int b)
{
return a+b;
}
static int add(int a,int b,int c)
{
return a+b+c;
}
}
class TestOverloading1
{
public static void main(String[] args)
{
System.out.println(Addition.add(21,21));
System.out.println(Addition.add(21,21,21));
}
}
Output:
42
63