View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule4832nocstylearray;
2   
3   /** Test case for ArrayTypeStyle (Java vs C). */
4   public class InputNoCstyleArrays {
5     private int[] javastyle = new int[0];
6     private int cstyle[] = new int[0]; // violation 'Array brackets at illegal position.'
7   
8     /** some javadoc. */
9     public static void mainJava(String[] javastyle) {} // ok
10  
11    /** some javadoc. */
12    public static void mainC(String cstyle[]) { // violation 'Array brackets at illegal position.'
13      final int[] blah = new int[0]; // ok
14      final boolean isok1 = cstyle instanceof String[]; // ok
15      final boolean isok2 = cstyle instanceof java.lang.String[]; // ok
16      final boolean isok3 = blah instanceof int[]; // ok
17      int[] array[] = new int[2][2]; // violation 'Array brackets at illegal position.'
18      int array2[][][] = new int[3][3][3];
19      // 3 violations above:
20      //                    'Array brackets at illegal position.'
21      //                    'Array brackets at illegal position.'
22      //                    'Array brackets at illegal position.'
23    }
24  
25    /** some javadoc. */
26    public class Test {
27      public Test[] variable; // ok
28  
29      public Test[] getTests() {
30        return null;
31      }
32  
33      public Test[] getNewTest() { // ok
34        return null;
35      }
36  
37      public Test getOldTest()[] { // violation 'Array brackets at illegal position.'
38        return null;
39      }
40  
41      // 2 violations 3 lines below:
42      //                    'Array brackets at illegal position.'
43      //                    'Array brackets at illegal position.'
44      public Test getOldTests()[][] {
45        return null;
46      }
47  
48      public Test[] getMoreTests()[] { // violation 'Array brackets at illegal position.'
49        return null;
50      }
51  
52      public Test[][] getTests2() { // ok
53        return null;
54      }
55    }
56  
57    int[] array[] = new int[2][2]; // violation 'Array brackets at illegal position.'
58    int array2[][][] = new int[3][3][3];
59    // 3 violations above:
60    //                    'Array brackets at illegal position.'
61    //                    'Array brackets at illegal position.'
62    //                    'Array brackets at illegal position.'
63  }