Suppose I have an array declared as
int[] unordered = {3, 4, 5, 1, 2};
and I want to create a new array, a, with a size 25% greater than that of unordered which has the original contents in order, followed by the indices that have not yet been assigned a value (i.e. 1, 2, 3, 4, 5, 0, 0, 0). How would I do this using System.arraycopy? Currently, what I have is:
int[] a = new int[(int)(unordered.length*.25)];
System.arraycopy(items, 3, a, 0, unordered.length-3);
System.arraycopy(items, 0, a, unordered.length-3, 3);
When I run this code, I get an array out of bounds error.
1.25in order to make the array 25% larger. Right now you are making it smaller.