View Javadoc
1   /*
2   MultipleVariableDeclarations
3   
4   
5   */
6   
7   package com.puppycrawl.tools.checkstyle.checks.coding.multiplevariabledeclarations;
8   
9   public class InputMultipleVariableDeclarations
10  {
11      int i, j; // violation 'Each variable declaration must be in its own statement.'
12      int i1; int j1; // violation 'Only one variable definition per line allowed.'
13  
14      void method1() {
15          String str, str1; // violation 'Each variable declaration must be in its own statement.'
16          Object obj; Object obj1; // violation 'Only one variable definition per line allowed.'
17      }
18      // second definition is wrapped
19      // line of VARIABLE_DEF is not the same as first line of the definition
20      java.lang.String string; String // violation 'Only one variable definition per line allowed.'
21          strings[];
22      //both definitions are wrapped
23      java.lang. // violation 'Only one variable definition per line allowed.'
24          String string1; java.lang.String
25              strings1[];
26  
27      void method2() {
28          for (int i=0, j=0; i < 10; i++, j--) {
29          }
30  
31          for(int i=0; i<4;i++) {
32  
33          }
34  
35          switch("") {
36          case "6":
37              int k = 7;
38          }
39      }
40  
41      void method3() {
42          java.lang.Object obj; Object obj1; Object obj2; Object obj3; // 3 violations
43          for (String s : new String[] {}) {}
44      }
45  }