Im having a big problem with this code: I need to create my own Merge Method without using java´s Merge Method.
public static <T extends Comparable> T[] merge(T[] a, T[] b){
T[] c = (T[]) new Object[a.length + b.length];
/*
*
* More code
*
*
*/
return c;
}
The problem is that in runtime I have this error: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Comparable; I have already looked for this problem, and the solution is using Reflection.
The problem i have it in this line: T[ ] c = (T[ ]) new Object[a.length + b.length];
The problem is that I dont understand how to use it, have already try using reflection in many different ways but i can´t solve this.
I really appreciate any answer and tell me where should I change my code.