Method Signature

Method Signature

In this tutorial, we are going to discuss Method Signature in java. A method signature typically refers to the declaration of a method, including its name, return type, and parameter types. It does not include the method’s implementation.

public static int minimum(int x, int y) {

}

Here minimum(int x, int y) 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.

Method Signature
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 signatures are used to uniquely identify methods within a class and to overload methods (define multiple methods with the same name but different parameter lists).

That’s all about method signature in Java. If you have any queries or feedback, please write us email at contact@waytoeasylearn.com. Enjoy learning, Enjoy Java.!

Method Signature
Scroll to top