Ok, so to
add an element to the end of an array, you have to create a larger array and do some copying, so something like this:
public static int[] addToArray(int[] arr, int ele, int ind)//parameters are array to add to, an element you want to add, where you want to add it
{
int[] arrFin = new int[arr.length+1];//creates a new array with length arr.length+1
int lastIndex = 0;//indexing variable for arrFin
for(int i = 0; i < arrFin.length; i++, lastIndex++)//for loop to fill array will values from arr
{
if(lastIndex==ind)//adds ele to arrFin when lastIndex equals ind
{
arrFin[lastIndex] = ele;
lastIndex++;//increments lastIndex
}
arrFin[lastIndex] = arr[i];//adds the next element in arr
}
return arrFin;//returns the new array
}
Which is MFThomas's original question, right?