Consider this example of valid code:
What is the reason that the following isn't allowed?Code:class Test<E> { E[] array; Test() { array = (E[]) new Object[100]; } }
It seems stupid that this isn't allowed because the original code is unelegant and will generate a warning. It is also a needed construction in a lot of containers.Code:array = new E[100];
I don't see any reason why the 'new E'-notation shouldn't be allowed. It doesn't create any E objects, so E doesn't have to be a known type.
I've asked my lecturer, but she doesn't have an answer.