View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="NoWhitespaceBefore"/>
5     </module>
6   </module>
7   
8   
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.whitespace.nowhitespacebefore;
12  
13  import com.google.common.collect.Lists;
14  
15  // xdoc section -- start
16  class Example1 {
17    int foo = 5;
18    void example() {
19      foo ++; // violation 'is preceded with whitespace'
20      foo++;
21      for (int i = 0 ; i < 5; i++) {}  // violation '';' is preceded with whitespace'
22      for (int i = 0; i < 5; i++) {}
23      int[][] array = { { 1, 2 }
24                      , { 3, 4 } }; // violation '',' is preceded with whitespace'
25      int[][] array2 = { { 1, 2 },
26                         { 3, 4 } };
27      Lists.charactersOf("foo").listIterator()
28             .forEachRemaining(System.out::print)
29             ; // violation '';' is preceded with whitespace'
30      {
31        label1 : // violation '':' is preceded with whitespace'
32        for (int i = 0; i < 10; i++) {}
33      }
34  
35      {
36        label2:
37        while (foo < 5) {}
38      }
39    }
40  }
41  // xdoc section -- end