0

When I create array of LinkedList (of Integers) like this,

new LinkedList<Integer>[V];

it gives me error saying "Generic Array creation"

but when I create array like this

new LinkedList[V];

it works fine.

What is this error and what's going wrong here ?

5
  • What's the problem? Creating an array of a generic type is not allowed. Commented Nov 13, 2018 at 17:02
  • 1
    Generic creation of array is not allowed in JAVA. See this post [stackoverflow.com/questions/7131652/… Commented Nov 13, 2018 at 17:04
  • Could you please tell me what's the difference between the 2 Commented Nov 13, 2018 at 17:06
  • Please visit the link. Its well explained. If you have further doubt post a new question. Commented Nov 13, 2018 at 17:16
  • @SubhasishBhattacharjee you can create an array with a generic element type: it just has to be reifiable, e.g. new ArrayList<?>[V] is allowed. Commented Nov 13, 2018 at 17:22

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.