Hi all,
I have a dumb silly question, but sometimes you have to ask them anyways.
I got an Object[] instance in my left hand (it comes from non-generic swing) and a method that accepts a let's say Integer[] as its argument (in my case it's actually a vararg) in my right hand. I'm sure of the content of the array (or I'm ready to pay the price if I'm wrong).
So basically I wrote that :
private static <U, T extends U> T[] cast(final U[] input, final Class<T> newType) {
//noinspection unchecked
final T[] result = (T[]) Array.newInstance(newType, input.length);
System.arraycopy(input, 0, result, 0, input.length);
return result;
}
can you remove the unchecked warning, without unplugging it ?
why haven't Array.newInstance() been genericized ?