Does the use final
in method arguments allow the compiler oor runtime environment to work faster? For example, if you have a variable to pass to a method that you know will not be modified and be used as is, is it more efficient to declare it final
?
Example: The first method should be faster than the second method
public int isLargerAfterTripledFaster(int num, final int limit) {
num *= 3;
return (num > limit);
}
public int isLargerAfterTripled(int num, int limit) {
num *= 3;
return (num > limit);
}
If I can be sure I will never want to pass a modifiable variable here, should I do this technique?