Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

----- > Method Overloading Question < -----

807597Nov 6 2005 — edited Jan 14 2007
overloading requires methods with distinct signatures. The signature of a method includes its name and the ordered list of its argument types. all other items appearing in a method header, such as exceptions, return type, final, and synchronized, do not contribute to a method's signature......

please correct me if i'm wrong, does it mean that:

(1) the list of argument types (int, int, float) must be in different order like (int, float, int) , (float, int, int) , (int, int), (int, float) ... in order to overload?
(2) the list of arguments (d, e, f) can be in any order like (d,e,z) , (a, b),(dx,ey,fz) or anything else?

Take the following case as an example,
public class MethodOverload{
  private int x, y;
  private float z;

  public void A(int d, int e, float f){
    x = d;
    y = e;
    z = f;
}
Can A method be overloaded as below?
public void A(int dx, int ey, float fz){
  x = dx;
  y = ey;
  z = fz;
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 11 2007
Added on Nov 6 2005
16 comments
679 views