What does the "final" modifier mean on a method parameter and when should I use it?

John Mitchell

The capability of using the final modifier on formal parameters was introduced in the Java 1.1 update. Basically, it's just like using final on a class field. That is to say that using it tells readers and the compiler that that parameter will not be modified in the method.

Note that the use of final on a formal parameter is not part of the method's signature. I.e., the modifier can be added or removed from subclass implementations of that method.

Note also that using final on a reference variable does not mean that you can't change the value that the reference points to -- only that you won't change the reference itself.

So, use the final modifier on formal paramaters to methods when you want to make it clear that the supplied value is not modified by that method.