It’s because Java’s arrays (unlike generics) contain, at runtime, information about its component type. So you must know the component type when you create the array. Since you don’t know what T
is at runtime, you can’t create the array.
More Related Contents:
- Java generics type erasure: when and what happens?
- Java erasure with generic overloading (not overriding)
- Class is a raw type. References to generic type Class should be parameterized
- Type erasure, overriding and generics
- What is PECS (Producer Extends Consumer Super)?
- Difference between
- Is there a way to refer to the current type with a type variable?
- Get type of a generic parameter in Java with reflection
- Generic arrays in Java
- Explanation of the get-put principle
- Java type inference: reference is ambiguous in Java 8, but not Java 7
- Java 1.6: Creating an array of List
- Java: Instanceof and Generics
- Reference is ambiguous with generics
- Java: Array of primitive data types does not autobox
- Java Class.cast() vs. cast operator
- What’s the point of Guava’s Optional class
- How do I find out what type each object is in a ArrayList?
- What are Reified Generics? How do they solve Type Erasure problems and why can’t they be added without major changes?
- Explanation of generic
- What is the difference between bounded wildcard and type parameters?
- Java HashMap nested generics with wildcards
- Create a List of primitive int?
- Java collections covariance problem
- Get type name for generic parameter of generic class [duplicate]
- Generic method in Java without generic argument
- Using a generic type with Gson
- How to write a generic method that takes two arguments of the same types in java?
- Java generics: wildcard vs type parameter?
- Provide an iterator over the contents of two lists simultaneously?