1 /*xml 2 <module name="Checker"> 3 <module name="TreeWalker"> 4 <module name="FinalLocalVariable"> 5 <property name="tokens" value="VARIABLE_DEF,PARAMETER_DEF"/> 6 </module> 7 </module> 8 </module> 9 */ 10 11 12 package com.puppycrawl.tools.checkstyle.checks.coding.finallocalvariable; 13 14 // xdoc section -- start 15 class Example2 16 { 17 static int foo(int x, int y) { 18 // 2 violations above: 19 // 'Variable 'x' should be declared final' 20 // 'Variable 'y' should be declared final' 21 return x+y; 22 } 23 public static void main (String []args) { 24 // violation above, 'Variable 'args' should be declared final' 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