R
res7cxbi
Just Curious...
Why can't i initialize a generic array like this?
private E[] data = new E[10];
This creates a compiler error saying that i can't intialize generic
arrays
The only workaround i've seen (the Collections class do this too) is
this:
private E[] data = (E[]) new Object[10];
so the question is...
Why Didn't The Creators Of Java Allow For Generic Array Intialization?
Why can't i initialize a generic array like this?
private E[] data = new E[10];
This creates a compiler error saying that i can't intialize generic
arrays
The only workaround i've seen (the Collections class do this too) is
this:
private E[] data = (E[]) new Object[10];
so the question is...
Why Didn't The Creators Of Java Allow For Generic Array Intialization?