Method Signature

Method Signature

In java method signature consists of method name and arguments list ( including order also).

public void m1(int i, float f) {

}

Here m1(int i, float f) is method signature. Compiler uses method signature to resolve method calls.

Two methods with the same signature are not allowed in any java class, violation leads to compile time error.

public class Test {
   public void m1(int i) {
   }
   
   public void m2() {
   }
   
   public int m1(int i) {
   }
   
   public void m1(int i, float f) {
   }
}
C.E: m1(int) is already defined in Test

In java return type is not part of method signature.

Method Signature


Scroll to top