Method Signature - rahul00773/JavaConcepts GitHub Wiki
In Java, Method Signature consists of methods names followed by argument types.
Ex: public static int m1(int I, float f){
}
In this method signature is m1(int, float)
The return type is not part of the method signature in Java.
The compiler will use method Signature to resolve method calls.
class Test{
public void m1(int I){
}
public void m2(String s) {
} }
class Demo{
public static void main(String[] args ){
Test t = new Test();
t.m1(10);
t.m2(“rahul”);
T.m3(5.0); // Compile time error will come:
}}
Within a class two methods with the same signature not allowed.
class Test{
public void int m1(int x){
return x;
}
public void m1(int x){
} }