Quick revision
The short answer
A reifiable type is one whose full type information is available at run time: primitives, non-generic classes, raw types and unbounded wildcard types such as List<?>. Arrays check the type of every element stored in them at run time, which is impossible for a non-reifiable element type like List<String>, so new List<String>[10] is banned to prevent silent heap pollution. ArrayList works around it by storing an Object[] and casting on get, and when a typed array is really needed we take a Class<T> or an IntFunction<T[]>, as Collection.toArray(IntFunction) does; in APIs, a List<List<String>> is usually better than an array of generics.
What to remember
In this answer, we saw that reifiable types are those fully known at run time: primitives, non-generic classes, raw types and unbounded wildcards like List<?>. Arrays check every store against their component type at run time, which cannot work for a non-reifiable element type like List<String>, so generic array creation is banned to avoid silent heap pollution. ArrayList stores a private Object[] and casts on get, suppressing the unchecked warning in one controlled place, and when a typed array is needed we take a Class<T> or an IntFunction<T[]>, while in APIs a List of lists is usually the better choice.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A reifiable type is one whose full type information is available at run time: primitives, non-generic classes, raw types and unbounded wildcard types such as List<?>. Arrays check the type of every element stored in them at run time, which is impossible for a non-reifiable element type like List<String>, so new List<String>[10] is banned to prevent silent heap pollution. ArrayList works around it by storing an Object[] and casting on get, and when a typed array is really needed we take a Class<T> or an IntFunction<T[]>, as Collection.toArray(IntFunction) does; in APIs, a List<List<String>> is usually better than an array of generics.
Why this question is asked
The rule against generic array creation looks arbitrary until we see what would go wrong without it. Interviewers ask about reifiable types because the concept ties together erasure, arrays, varargs warnings and the way the JDK's own collections are written. In this answer, we will define reifiable types, see how arrays protect themselves at run time, walk through the heap pollution the ban prevents, look inside ArrayList to see how it manages without generic arrays, and finish with the options when a typed array is truly needed.
1What Makes a Type Reifiable
To reify something is to make it concrete. A reifiable type is one the JVM can fully represent at run time, so code can check it with instanceof or a cast. Because of erasure, type arguments are removed when Java compiles generic code, so most parameterised types are not reifiable: at run time a List<String> is just a List.
| Type | Reifiable? | Why |
|---|---|---|
| int, double | Yes | primitives are fully known |
| String, Order | Yes | non-generic classes |
| List (raw) | Yes | no type argument to lose |
List<?> | Yes | unbounded wildcard says nothing extra |
String[], List<?>[] | Yes | arrays of reifiable types |
List<String> | No | String is erased |
List<? extends Number> | No | the bound is erased |
| T | No | a type variable is erased to its bound |
2Arrays Check Their Element Type at Run Time
Arrays in Java are covariant: a String[] is a subtype of Object[]. That is convenient, but it would be unsafe if arrays did not protect themselves, so every array remembers its component type and checks each store.
This run-time store check is the whole reason arrays and generics clash. The check needs to know the component type exactly, and for List<String> the JVM only knows List.
3Why new List<String>[10] Is Illegal
Suppose the compiler allowed it. The array created at run time would really be a List[], because String is erased. The store check would then only check that each element is a List, so it would accept a List<Integer> too, without any warning.
- Create List<String>[1]really a List[] at run time
- Assign it to Object[]arrays are covariant
- Store List.of(42)store check only sees List
- Read lists[0].get(0) as Stringinserted cast fails
- ClassCastException far from the causeno warning anywhere
5 steps in order. Play them, or step through them one at a time.
Notice that the program would contain no unchecked warning at all, yet it would fail with a ClassCastException on a line that looks perfectly typed. That is heap pollution, a variable of type List<String> pointing at something that is not a list of strings, and it would be silent. Java's rule is that well-typed code without unchecked warnings never fails like this, so the compiler forbids creating the array instead. An array of List<?> is allowed, because List<?> promises nothing about the elements, so the check on List is complete.
4How ArrayList Manages Without Generic Arrays
ArrayList<E> needs an array internally, and it cannot create an E[]. So it does not try. It stores an Object[] and casts each element to E on the way out.
The cast to E is unchecked, and after erasure it does nothing. It is safe because the array is private and only methods taking an E ever store into it, so every element really is an E. That is the pattern for generic containers: keep an Object[] private, control every write, and suppress the warning in one small place with the reason written down. Exposing that array to callers as an E[] would be wrong, because it is really an Object[] and a caller expecting a String[] would fail at its own cast.
5When a Typed Array Is Really Needed
Sometimes an API must return a real typed array, for example to call a legacy method that takes String[]. The caller knows the type, so we let the caller provide it. Collection.toArray(IntFunction<T[]> generator), added in Java 11, takes a function that creates an array of the right type and size, and the older toArray(T[] a) uses the passed array as a template.
In our own APIs, though, the best answer is usually not to use arrays of generics at all. A List<List<String>> has none of these problems, is easier to use with streams, and costs very little more. Arrays are best kept for primitives and for internal storage.
6Follow-up questions
Why are generic varargs allowed if generic arrays are not?
A varargs parameter T... or List<String>... is an array, so calling it creates exactly the kind of array the ban forbids. Java allows it because varargs are so useful, but it warns about possible heap pollution and offers @SafeVarargs for methods that do not misuse the array.
Is List<?>[] really safe?
Yes. Its store check confirms each element is a List, and List<?> claims nothing more, so there is nothing the check can miss. Reading from it gives List<?>, and we must check element types ourselves.
Why are arrays covariant but generics are not?
Arrays were covariant before generics existed, so methods like Arrays.sort(Object[]) could accept any array, and the run-time store check made it safe. Generics chose invariance with wildcards because they have no run-time check to fall back on.
7Conclusion
In this answer, we saw that reifiable types are those fully known at run time: primitives, non-generic classes, raw types and unbounded wildcards like List<?>. Arrays check every store against their component type at run time, which cannot work for a non-reifiable element type like List<String>, so generic array creation is banned to avoid silent heap pollution. ArrayList stores a private Object[] and casts on get, suppressing the unchecked warning in one controlled place, and when a typed array is needed we take a Class<T> or an IntFunction<T[]>, while in APIs a List of lists is usually the better choice.
Open with
A reifiable type is a type the JVM fully knows at run time: primitives, ordinary classes, raw types, unbounded wildcard types like List<?>, and arrays of those. List<String> is not reifiable, because erasure removes String.
Then, if they want more
Arrays need reifiable component types because they check every store at run time; that is what makes covariant arrays safe, so storing an Integer into a String[] seen as Object[] throws ArrayStoreException.
If new List<String>[10] were allowed, the real array would be a List[], its store check would accept a List<Integer>, and code with no warnings at all would later throw ClassCastException when reading a string. That silent heap pollution is why generic array creation is a compile error.
ArrayList shows the workaround: it keeps a private Object[] and casts to E on get, with the unchecked warning suppressed in one place, which is safe because only add(E) writes into the array.
When I genuinely need a typed array, I let the caller provide the type, either an IntFunction like String[]::new, as Collection.toArray does since Java 11, or a Class<T> with Array.newInstance. And in my own APIs I prefer List<List<String>> over arrays of generics.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 11
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What is a reifiable type? Why is new List<String>[10] illegal and how do you work around...": https://scrivio-interview-library.netlify.app/java/generics/1455e15034/