I was messing around trying to figure this out and came up with this. This works but I'm looking for a more elegant recursive solution. Can anyone think of one? I couldn't find anything with google. Oh and sorry for the stupid variable names.
public class arraybackwards {
public static void main(String[] args){
int[] bob = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
int[] toSend = new int[bob.length];
int index = 0;
bob = backwards(bob,toSend,bob.length, index);
for(int i = 0; i < bob.length; i++){
System.out.print(bob[i] + " ");
}
}
public static int[] backwards(int[] arg, int[] toSend, int length, int index){
if (length > 0)
{
int bob = arg[length-1];
toSend[index] = bob;
backwards(arg,toSend,length-1,++index);
}
return toSend;
}
}