Forums Register Login

Question about Generics in Arrays

+Pie Number of slices to send: Send
Hi folks,
i dont get where the problem is with this line:

List <Integer> i[] = {new ArrayList<Integer>(), new ArrayList<Integer>()};

PS: It is not a copy of any mock test. Just a pervert idea from a colleague at work. :-)
+Pie Number of slices to send: Send
Hi Frank,
Java generics don't permit creation of Arrays of generics.That's why you are getting error.

thanks
mayur
+Pie Number of slices to send: Send
But why is it so?
+Pie Number of slices to send: Send
List <?> i[] = {new ArrayList<Integer>(), new ArrayList<Integer>()};
why above code compiles?
+Pie Number of slices to send: Send
Already discussed ,
see this
+Pie Number of slices to send: Send
http://www.bloggingaboutjava.org/2006/01/java-generics-quirks/
thanks Sagar Rohankar
I gone thru your link and I found very useful info of above link at your posted link

Thanks

Regards
Ninad
+Pie Number of slices to send: Send
Thanks ranchers.
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 893 times.
Similar Threads
Generics
Scriptlets
List with a sublist of Integers
Difference between ArrayList<int> and ArrayList<Integer>
how to add an array to an ArrayList
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:37:40.