I am trying to create a generic Array in Java below the code snippet.
static<T extends Comparable<? super T>> T[] exactlyOnce(T[] A){
T[] temp , B;
temp = (T[])new Object[A.length];
B = (T[])new Object[A.length];
//Rest of the code follows
}
It produces following exception not sure on how to resolve this.
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Comparable;