Reading Robert Sedgewick's book on algorithms, I always see him mention that in java arrays of things that hold other generic things, need to be created like so:
Foo<Bar>[] foo = (Foo<Bar>[])new Foo[N];
So I was wondering if that cast is necessary, because when I do:
Foo<Bar>[] foo = new Foo[N];
the compiler still seems to know that the generic type is Bar.
So, is it necessary, and what is the point of it?