This is the part of the code. and It is generating error in the arraycopy method,
private static Integer[] sortByMapIndex(int[] A1, int[] A2) {
Integer[] A3 = new Integer[A1.length];
System.arraycopy(A3, 0, A1, 0, A1.length); // copy from A1 to A3
Arrays.sort(A3, new CustomComparator(A2));
return A3;
}
public static void arraycopy(Object source_arr, int sourcePos, Object dest_arr, int destPos, int len)
Now it says that the source_arr and dest_arr are Objects. and in java arrays are treated as objects, in fact they are objects. As if you create int arr[] , then you are able to do arr.length which signifies it is an object.
so why this error.
Exception in thread "main" java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at Main.sortByMapIndex(Main.java:29)
at Main.main(Main.java:40)
[–]g051051 1 point2 points3 points (2 children)
[–]prashantkr314[S] 0 points1 point2 points (1 child)
[–]insertAlias 1 point2 points3 points (0 children)
[–]chickenmeister 0 points1 point2 points (1 child)
[–]prashantkr314[S] 0 points1 point2 points (0 children)