Pregunta

you can set within eclipse the code style to use modifier 'final' where possible. Unfortunately this modifier is also set in interfaces. But there it doesn't make sense. Is it possible to prevent setting the modifier 'final' for method parameters in interfaces? Only to set it clear.. i mean not fields. These are always final and static. I mean method params like 'param'

public interface MyService {
   void aMethod(String param);
}

instead of

public interface MyService {
   void aMethod(final String param);
}

The 'final' does not change the logic of the code, but it is unnecessary.

¿Fue útil?

Solución

You can't specify behavior for an interface vs a class, but you can make it stop putting final on parameters.

Go to Preferences -> Java -> Code Style -> Clean Up, edit the profile and choose the Code Style tab. At the bottom, under Variable Declarations, uncheck the Parameter check box.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top