View Javadoc
1   /*
2   FinalLocalVariable
3   validateEnhancedForLoopVariable = (default)false
4   tokens = VARIABLE_DEF, PARAMETER_DEF
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.finallocalvariable;
10  
11  public class InputFinalLocalVariableInterface {
12      interface Test {
13          static void test (String param) { // violation, "Variable 'param' should be declared final"
14              String local = ""; // violation, "Variable 'local' should be declared final"
15              System.out.println (param);
16          }
17  
18          void method (int aParam);
19  
20          default void init (int aParam) {} // violation, "Variable 'aParam' should be declared final"
21  
22          // violation below, "Variable 'num' should be declared final"
23          static int parseInteger(String num) {
24              int result = 0;
25              try {
26                  result = Integer.parseInt(num);
27              }
28              catch (NumberFormatException e) {} // violation, "Variable 'e' should be declared final"
29              return result;
30          }
31      }
32  }