top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Why can’t we create generic array?

+3 votes
19 views

Why can’t we create generic array? or write code as List[] array = new ArrayList[10];

posted Aug 17, 2015 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote

it is because Java 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 List is at runtime, you can't create the array.

answer Apr 28, 2016 by Shivam Kumar Pandey
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...