This should be an easy question, but I can't seem to find the answer in the Java Class Library page
on arrays.
All I want to do is write a simple line of code which will return a new array from index x to index y of the old array. Writing this manually isn't hard, or especially tedious, I'll just do it here to prove I know how:
int x = 4;
int y = 6;
int counter = 0;
int [] firstArray = {1,2,3,4,5,6,7,8,9,10};
int [] secondArray = new int[10];
for (int i=x; i<=y; i++)
secondArray[counter++] = firstArray[i];
That's great. But I can't help but wonder if I'm missing something really obvious, like:
int[] secondArray = Array.splice(firstArray,4,7); // which would be like substring for arrays
Is such a method hidden somewhere that's not on the Java Class Library array page, or am I right to assume that it doesn't exist?