Method Overloading Verification
Hi.
I want to make sure I have the correct understanding of Method Overloading.
If the methods have the same name, BUT different formal parameter lists, they are method overload.
Exs.
Method Overload
public int methodABC (int a, char b, double c)
public int methodABC (char a, int b, double c)
Not Method Overload
If they have the same method name and the same formal lists they are NOT method overload.
public int methodABC (int a, char b, double c)
public int methodABC (int a, char b, double c)
What if they had same name, & they had the same formal list/signature, but the value/return type was different
public double methodABC (int a, char b, double c)
public int methodABC (int a, char b, double c)
Method Overloading Verification
Thanks for responding Tolls.
I think that there must be a one-to-one match between actual and formal parameters.
If there are 4 formal, then there should be 4 actual. Is that right?
Method Overloading Verification
KevinWorkman, this is my understanding.
Formal parameters are declared in the header:
public double pow (double x, double y)
Actual parameters are in the body (or when the method is called/used):
Code:
double x = 2.0;
double y = 2.0;
z = pow(x,y) or z = pow(2.0,2.0);
If this example is not correct, will someone please let me know.
Method Overloading Verification
Tolls, this is what I read:
"In a method call, the number of actual parameters, together with their dataa types, must match the formal parameters in the order given. That is, actual & formal parametes have a one-to-one correspondence." (Java Programming)
I found this on Google:
"When you call a subroutine, you must provide one actual parameter for each formal parameter in the subroutine's definition." (Java Programing: Section 4.3)
lala
Does anybody know for sure?
Method Overloading Verification
I don't know, Tolls. :confused:
Does anyone know if formal and actual parameters have to have a one-to-one match?
Thanks In Advance
Method Overloading Verification
Tolls, now that I re-think this, I don't think it matters if they do not match.
Method Overloading Verification
Yes Tolls, and all. The OP may have been " mixing different concepts and confusing matters." :)
Sorry about the confusion. I'm new to Java.
Many thanks to Everyone for your contributions.
:)