I haven\'t found anything with the specific needs of my function to do this, yes, it is for homework.
So I have:
public void reverseArray(int[] x) {
This is probably the easiest way, not the fastest, but probably the easiest.
A whole program would look something like this:
public static void main(String [] args)
{
BackwardsArray back = new BackwardsArray();
}
public BackwardsArray()
{
int [] a = {1,2,3,4,5,6,7,8,9};
printBackwards(a);
}
void printBackwards( int [] b)
{
print(b,b.length-1);
}
void print(int [] b, int pos)
{
System.out.println(b[pos]); // prints last item
if(pos != 0)
{
print(b,pos-1);
}
}
Hope it helps!