mardi 4 août 2015

Constructing objects for a user-defined generic Array in Java

If I defined my own generic array with this constructor:

public PublisherGenericArray(Class<E> c, int s)
{   
    // Use Array native method to create array  
    // of a type only known at run time
    @SuppressWarnings("unchecked")
    final E[] a = (E[]) Array.newInstance(c, s);
    this.a = a;
}

How do I create an object that satisfies the first parameter (class c)?

Basically:

PublisherGenericArray <String> newArray = new <String> PublisherGenericArray(???,newSize);

What would go in the first parameter labeled "???"



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire