View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="DescendantToken">
5         <property name="tokens" value="FOR_INIT"/>
6         <property name="limitedTokens" value="EXPR"/>
7         <property name="minimumNumber" value="1"/>
8       </module>
9     </module>
10  </module>
11  */
12  package com.puppycrawl.tools.checkstyle.checks.descendanttoken;
13  
14  // xdoc section -- start
15  class Example5 {
16    void testMethod1() {
17      for (int i = 0; i != 10; i++) {
18        System.out.println(i);
19      }
20      int k = 0;
21      for (; ; ) { // violation, 'Count of 0 for 'FOR_INIT' descendant'
22        System.out.println(k);
23      }
24    }
25  
26    void testMethod2() {
27      int[] array = new int[] {1, 2, 3, 4, 5};
28      for (int i = 0; i != array.length; i++) {
29        System.out.println(i);
30      }
31      int j = 0;
32      // violation below, 'Count of 0 for 'FOR_INIT' descendant'
33      for (; j != array.length;) {
34        System.out.println(j);
35        j++;
36      }
37    }
38  }
39  // xdoc section -- end