KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > InputUnnecessaryParentheses


1 public class InputUnnecessaryParentheses {
2     int f1() {
3         int x = 0;
4         for (int i = (0+1); ((i) < (6+6)); i += (1+0)) {
5             x += (i + 100);
6             (x) += (i + 100);
7             x = (x + i + 100);
8             (x) = (x + i + 100);
9         }
10
11         for (int i = (0+1); (i) < ((6+6)); i += (1+0)) {
12             System.out.println("hi");
13         }
14
15         return (0);
16     }
17
18     private int f2(int arg1, double arg2) {
19         int x, a, b, c, d;
20         String JavaDoc e, f;
21
22         x = 0;
23         a = 0;
24         b = 0;
25         c = (a + b);
26         d = c - 1;
27
28         int i = (int) arg2;
29         i = ((int) arg2);
30
31         x += (i + 100 + arg1);
32         a = (a + b) * (c + d);
33         b = ((((a + b) * (c + d))));
34         c = (((a) <= b)) ? 0 : 1;
35         d = (a) + (b) * (600) / (int) (12.5f) + (int) (arg2);
36         e = ("this") + ("that") + ("is" + "other");
37         f = ("this is a really, really long string that should be truncated.");
38
39         return (x + a + b + d);
40     }
41
42     private boolean f3() {
43         int x = f2((1), (13.5));
44         boolean b = (true);
45         return (b);
46     }
47
48     public static int f4(int z, int a) {
49         int r = (z * a);
50         r = (a > z) ? a : z;
51         r = ((a > z) ? a : z);
52         r = (a > z) ? a : (z + z);
53         return (r * r - 1);
54     }
55
56     public void f5() {
57         int x, y;
58         x = 0;
59         y = 0;
60         if (x == y) {
61             print(x);
62         }
63         if ((x > y)) {
64             print(y);
65         }
66
67         while ((x < 10)) {
68             print(x++);
69         }
70
71         do {
72             print((y+=100));
73         } while (y < (4000));
74     }
75
76     private void f6(TypeA a) {
77         TypeB b = (TypeB) a;
78         TypeC c = ((TypeC) a);
79         int r = 12345;
80         r <<= (3);
81         TypeD<String JavaDoc> d = ((TypeD<String JavaDoc>) a);
82     }
83
84     private void print(int arg)
85     {
86         System.out.println("arg = " + arg);
87     }
88
89     static class TypeA {}
90     static class TypeB extends TypeA {}
91     static class TypeC extends TypeA {}
92     static class TypeD<T> extends TypeA {}
93 }
94
Popular Tags