Search code examples
javainterfacefinal

What difference does it make to declare a Java interface method signature as final and non-final


what difference does it make in a Java Interface to declare the method signature as final and non-final?

int setName(String name);

int setName(final String name);

Solution

  • Section 8.4.1 of the Java Language specification allows the parameters in any method declaration (and that includes the ones in interfaces) to be declared final. However, since this does not influence the method's signature, declaring a parameter of an abstract function as final has no effect. Since all methods in an interface are implicitely abstract, both variants are equivalent.