-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample132.java
More file actions
33 lines (25 loc) · 1.01 KB
/
Example132.java
File metadata and controls
33 lines (25 loc) · 1.01 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
29
30
31
32
// Example 132 from page 101
//
import java.util.*;
class G<T> { }
class Example132 {
public static void main(String[] args) {
new F<Double>().M();
}
}
class F<T> {
public void M() {
T[] tarr; // Legal declaration
G<T>[] ctarr; // Legal declaration
G<Integer>[] ciarr; // Legal declaration
// tarr = new T[5]; // Illegal generic array creation
// ctarr = new G<T>[5]; // Illegal generic array creation
// ciarr = new G<Integer>[5]; // Illegal generic array creation
ArrayList<T> tlist; // Legal declaration
ArrayList<G<T>> ctlist; // Legal declaration
ArrayList<G<Integer>> cilist; // Legal declaration
tlist = new ArrayList<T>(); // Legal array list creation
ctlist = new ArrayList<G<T>>(); // Legal array list creation
cilist = new ArrayList<G<Integer>>(); // Legal array list creation
}
}