KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > usage > InputUnusedLocal


1 package com.puppycrawl.tools.checkstyle.usage;
2
3 import java.awt.Rectangle JavaDoc;
4
5 /** Test input for unused local variable check */
6 public class InputUnusedLocal
7 {
8     private int mUnreadPrimitive = 0;
9     
10     public InputUnusedLocal()
11     {
12         int readPrimitive = 0;
13         int mUnreadPrimitive = 0;
14         int i = readPrimitive;
15         i++;
16        
17        this.mUnreadPrimitive++;
18     }
19
20     private void method()
21     {
22         String JavaDoc readObject = "";
23         Rectangle JavaDoc rectangle = null;
24         Object JavaDoc unreadObject;
25         int i = readObject.length();
26         
27         int j = rectangle.x;
28         
29         i += j;
30         }
31
32     private void methodArrays()
33     {
34         int[] array = {};
35         int[] array2 = {};
36         int[] unreadArray;
37         int i = array[0];
38         array2[0] = 0;
39         i++;
40     }
41     
42     /** tests that neither type nor typecast are considered to be a reference */
43     public void method2()
44     {
45         int java;
46         java.io.File JavaDoc file = (java.io.File JavaDoc) null;
47         if (file != null) {
48         }
49     }
50     
51     /** tests array index references */
52     public void testArrayIndex()
53     {
54         int [][][] a = new int[1][1][1];
55         int i = 0;
56         int j = 0;
57         int k = 0;
58         a[i][j][k]++;
59     }
60 }
61
Popular Tags