View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="FinalLocalVariable"/>
5     </module>
6   </module>
7   */
8   
9   
10  
11  
12  
13  
14  package com.puppycrawl.tools.checkstyle.checks.coding.finallocalvariable;
15  
16  // xdoc section -- start
17  class Example1
18  {
19    static int foo(int x, int y) {
20      //ok, because PARAMETER_DEF is not configured in tokens
21      return x+y;
22    }
23    public static void main (String []args) {
24      //ok above, because PARAMETER_DEF is not configured in tokens
25      //ok below, because validateEnhancedForLoopVariable is false by default
26      for (String i : args) {
27        System.out.println(i);
28      }
29      int result=foo(1,2); // violation, 'Variable 'result' should be declared final'
30    }
31  }
32  // xdoc section -- end