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