-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathStaticArray.java
More file actions
28 lines (20 loc) · 1.27 KB
/
StaticArray.java
File metadata and controls
28 lines (20 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class StaticArray
{
public static final int[] bad = new int[42]; //NOT OK
protected static final int[] good_protected = new int[42]; //OK (protected arrays are ok)
/* default */ static final int[] good_default = new int[42]; //OK (default access arrays are ok)
private static final int[] good_private = new int[42]; //OK (private arrays are ok)
public final /* static */ int[] good_nonstatic = new int[42]; //OK (non-static arrays are ok)
public /* final */ static int[] good_nonfinal = new int[42]; //OK (non-final arrays are ok)
public static final Object good_not_array = new int[42]; //OK (non-arrays are ok)
public static final int[][][] bad_multidimensional = new int[42][42][42]; //NOT OK
public static final int[][][] bad_multidimensional_partial_init = new int[42][][]; //NOT OK
public static final int[] bad_separate_init; //NOT OK
static {
bad_separate_init = new int[42];
}
public static final int[] good_empty = new int[0]; //OK (empty array creation)
public static final int[] good_empty2 = {}; //OK (empty array literal)
public static final int[][] good_empty_multidimensional = new int[0][42]; //OK (empty array)
public static final int[][] bad_nonempty = { {} }; //NOT OK (first dimension is 1, so not empty)
}