1

I am trying to parse a generic array list to an array using standard methodology, but an error throws when converting an Object list to SimpleEntry list. Here is my code:

// Start with ArrayList of simple entries
AbstractMap.SimpleEntry<E, Integer>[] entries = (AbstractMap.SimpleEntry<E, Integer>[] ) new Object[arraylist.size()];
// Fill array with AL elements

What is the issue with this?

The error is as follows:

[Ljava.lang.Object; cannot be cast to [Ljava.util.AbstractMap$SimpleEntry;
Ryan Cocuzzo
  • 2,538
  • 4
  • 28
  • 51

1 Answers1

1

Considering what you posted, you will have a list at the end, maybe this will help you:

        AbstractMap.SimpleEntry<E, Integer>[] entries2 = new AbstractMap.SimpleEntry[arr.size()];

        // or this      
        SimpleEntry<E, Integer>[]  entries =  new SimpleEntry[arr.size()];
jhenrique
  • 768
  • 1
  • 9
  • 14