In a class have multiple method by same name but have different parameter, it is knows as method Overloading.
While Talking about method, it is important to know the different between two terms parameter and argument.
Parameter is a variable defined be a method that receives value when the method is called. parameter are always local to the method they dont have scope outside the method
While argument is a value that is passed to a method when it called.
package sumadding;
public class methodload {
void sum(int a, int b) {
System.out.println("Sum of two number interger number " + (a+b));
}
void sum (float a, float b)
{
System.out.println("Sum of two number interger number " + (a+b));
}
void sum(double d, double e) {
{
System.out.println("Sum of two number interger number " + (d+e));
}
}
public static void main(String[] args) {
methodload d = new methodload();
d.sum(3,8);
d.sum(4.7,6.5);
d.sum(4,98);
}
}
While Talking about method, it is important to know the different between two terms parameter and argument.
Parameter is a variable defined be a method that receives value when the method is called. parameter are always local to the method they dont have scope outside the method
While argument is a value that is passed to a method when it called.
package sumadding;
public class methodload {
void sum(int a, int b) {
System.out.println("Sum of two number interger number " + (a+b));
}
void sum (float a, float b)
{
System.out.println("Sum of two number interger number " + (a+b));
}
void sum(double d, double e) {
{
System.out.println("Sum of two number interger number " + (d+e));
}
}
public static void main(String[] args) {
methodload d = new methodload();
d.sum(3,8);
d.sum(4.7,6.5);
d.sum(4,98);
}
}