Understanding array of ArrayLists

Shubham Urkade :

I'm creating an array of ArrayLists using the following code:

ArrayList<Integer>[] list = new ArrayList[n];

As it is said that array of generics is not allowed. How is that my code compiles?

A.Najafi :

Because you are initializing an array not the ArrayList Look at this:

ElementType [] name = new ElementType[size];

Here your element type is ArrayList

Look at this site:Array of ArrayList

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=102302&siteId=1