Does a method's signature in Java include its return type?
Quoting from Oracle Docs:
Definition: Two of the components of a method declaration comprise the method signature—the method's name and the parameter types.
Since the question was edited to include this example:
public class Foo {
public int myMethod(int param) {}
public char myMethod(int param) {}
}
No, the compiler won't know the difference, as their signature: myMethod(int param)
is the same. The second line:
public char myMethod(int param) {}
will give you can error: method is already defined in class, which further confirms the above statement.
Is class method signature in Java includes return type ?
In Java, it doesn't but in this JVM it does which can lead to obvious confusion.
Is interface method signature in Java includes return type ?
The same as for class methods.
Or only method name and parameters list ?
Method name and parameter types for Java. For example, the parameter annotations and names don't matter.