0

I'm trying to create generic array in java but it results in error. Can any one help me on this?

Please find my code below:

public class GenericArrayTest<TKey extends Comparable,TValue>
                                   implements Iterable<Map.Entry<TKey,TValue>> {
  private TKey[] _arrayCOll;

  public void test(){
    _arrayCOll = new TKey[10];//error "Cannot create a generic array of TKey"
  }

  @Override
  public Iterator<Entry<TKey, TValue>> iterator() {
        // TODO Auto-generated method stub
        return null;
  }

}

Note: I could not know the class type so that i could not use the below solution How to create a generic array in Java?

Thanks in advance. Sarath

sarath kumar
  • 179
  • 4
  • 11

0 Answers0