A method signature is part of the method declaration where a signature is a combination of the method name and parameter list. Method signature doesn’t consider return type as part of the signature.
The main reason to emphasis on method Signature is because of method overloading. Java compiler distinguishes between the methods based on the method signature.
See Also:
- Java: Method Signature
- Java: Method Overloading
- Java: Method Overriding
- Java: Method Overloading Vs Method Overriding
- Exception handling with method overriding
Method Overloading :
Method overloading provides the ability to write methods with the same name but accept different arguments. Method Overloading is compile-time Polymorphism.
Here is one example of method overloading where add method implements by three ways:
- double add(double a, double b)
- int add(int a, int b)
- double add(int a, int b)
Method signature doesn’t consider return type for method overloading, it will consider method 2 and 3 as a duplicate method and return this compile-time error.
Duplicate method add(int, int) in type MethodSignatureExample
As shown in below screen shot.

Method Signature Examples
public void getMapLocation(int xPos, int yPos) { //method code }
The method signature in the above example is getMapLocation(int, int). In other words, it’s the method name (getMapLocation) and the parameter list of two integers.
public void getMapLocation(Point position) { //method code }
The Java compiler will allow adding another method because its method signature is different, getMapLocation(Point).
You must be logged in to post a comment.