2015-09-07 11:44:36 -06:00
|
|
|
|
// arrays/ArrayOfGenericType.java
|
2015-06-15 17:47:35 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
|
|
|
|
// Arrays of generic types won't compile.
|
|
|
|
|
|
|
|
|
|
public class ArrayOfGenericType<T> {
|
|
|
|
|
T[] array; // OK
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public ArrayOfGenericType(int size) {
|
|
|
|
|
//! array = new T[size]; // Illegal
|
|
|
|
|
array = (T[])new Object[size]; // "unchecked" Warning
|
|
|
|
|
}
|
|
|
|
|
// Illegal:
|
|
|
|
|
//! public <U> U[] makeArray() { return new U[10]; }
|
2015-09-07 11:44:36 -06:00
|
|
|
|
}
|