I was reading at the Oracle java API document about System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length) method. ArrayStoreException is thrown when the src/dest argument refers to an object that is not an array. Then is it possible to to use Arrays or T[] in the method declaration? Something like:
System.arraycopy(Arrays src, int srcPos, Arrays dest, int destPos, int length)
or
System.arraycopy(T[] src, int srcPos, T[] dest, int destPos, int length)
T[]can't be an array of primitives, while anObjectcan. Also, that method predates generics. And,Arraysis a collection of static helper methods; not an array.srcanddestare both arrays of a reference type, then they don't have to be the same type. For example, you can copy anObject[]to aString[]as long as all elements in theObject[]are instances of classString.srcanddestare arrays of different typessrcanddestbeing arrays of different types either way.