KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > InputDefaultComesLast


1 public class InputDefaultComesLast
2 {
3     void method(int i) {
4         // switch with last default
5
switch (i) {
6         case 1: break;
7         case 2: break;
8         default:
9             // do something :)
10
}
11
12         // switch w/o default (not a problem)
13
switch (i) {
14         case 1: break;
15         case 2: break;
16         }
17
18         // VIOLATION!!! default is not the last one.
19
switch (i) {
20         case 1:
21             break;
22         default:
23             break;
24         case 2:
25             break;
26         }
27     }
28 }
29
30 @interface InputDefaultComesLastAnnotation
31 {
32     int blag() default 1;
33 }
Popular Tags