1
2
3
4
5
6
7
8
9 package com.puppycrawl.tools.checkstyle.checks.coding.finallocalvariable;
10
11 public class InputFinalLocalVariable2Four {
12 class Class32 {
13 public void test1() {
14 final boolean b = true;
15 int shouldBeFinal;
16
17 if (b) {
18 shouldBeFinal = 1;
19 }
20 else {
21 shouldBeFinal = 2;
22 }
23 }
24
25 public void test2() {
26 final int b = 10;
27 int shouldBeFinal;
28
29 switch (b) {
30 case 0:
31 shouldBeFinal = 1;
32 break;
33 default:
34 shouldBeFinal = 2;
35 break;
36 }
37 }
38
39 public void test3() {
40 int x;
41 try {
42 x = 0;
43 } catch (final Exception e) {
44 x = 1;
45 }
46
47 int y;
48 try {
49 y = 0;
50 } finally {
51 y = 1;
52 }
53 }
54
55 public void test4() {
56 final boolean b = false;
57 int x;
58 if (b) {
59 x = 1;
60 } else {
61 x = 2;
62 }
63
64 if(b) {
65 x = 3;
66 }
67 }
68
69 public void test5() {
70 final boolean b = false;
71 int shouldBeFinal;
72 if(b) {
73 }
74 if (b) {
75 shouldBeFinal = 1;
76 } else {
77 shouldBeFinal = 2;
78 }
79 }
80 }
81 }