View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="DefaultComesLast">
5         <property name="skipIfLastAndSharedWithCase" value="true"/>
6       </module>
7     </module>
8   </module>
9   */
10  package com.puppycrawl.tools.checkstyle.checks.coding.defaultcomeslast;
11  
12  // xdoc section -- start
13  public class Example2 {
14  
15    public void method() {
16      int i = 2, x;
17      switch (i) {
18        case 1:
19          break;
20        case 2:
21          break;
22        default:
23          break;
24      }
25  
26      switch (i) {
27        case 1:
28          break;
29        case 2:
30          break;
31      }
32  
33      switch (i) {
34        case 1:
35          break;
36        default: // violation, 'Default should be last label in the switch'
37          break;
38        case 2:
39          break;
40      }
41  
42      switch (i) {
43        case 1:
44          break;
45        default: // violation, 'Default should be last label in the case group'
46        case 2:
47          break;
48      }
49  
50      switch (i) {
51        case 1: x = 9;
52        default: x = 10; // violation, 'Default should be last label in the switch'
53        case 2: x = 32;
54      }
55    }
56  }
57  // xdoc section -- end