S
Sebastian
Hello there,
how can I make the compile error go away? The marked line is wrong:
Type mismatch: cannot convert from Class<capture#2-of ?> to Class<T>
/**
* Copies the specified array to a new array with the same component
* type and length as the given array.
* @param <T> the type of the array elements
* @param src the array to be copied
* @return the copy
*/
public static final <T> T[] arraycopy( T[] src )
{
Class<T> componentType = src.getClass().getComponentType(); // !!!!
@SuppressWarnings("unchecked")
T[] dest = (T[]) Array.newInstance( componentType, src.length );
System.arraycopy( src, 0, dest, 0, src.length );
return dest;
}
I'd be grateful for a hint.
-- Sebastian
how can I make the compile error go away? The marked line is wrong:
Type mismatch: cannot convert from Class<capture#2-of ?> to Class<T>
/**
* Copies the specified array to a new array with the same component
* type and length as the given array.
* @param <T> the type of the array elements
* @param src the array to be copied
* @return the copy
*/
public static final <T> T[] arraycopy( T[] src )
{
Class<T> componentType = src.getClass().getComponentType(); // !!!!
@SuppressWarnings("unchecked")
T[] dest = (T[]) Array.newInstance( componentType, src.length );
System.arraycopy( src, 0, dest, 0, src.length );
return dest;
}
I'd be grateful for a hint.
-- Sebastian