I am writing a method that needs to do this.
/**
* This method reverses 'in place' the elements in
* the array. Reversing is defined as moving the
* elements in the array such that the first element
* becomes the last element, the second element
* becomes the second to last element, etc.
* <p>
here is what i have so far
Here is my tester class.
Which prints the result like this
The array [a, b, c, f, n, q, s] entered sqnfcbalooks like this in reverse order[a, b, c, f, n, q, s]
But it needs to print it like this.
The array [a, b, c, f, n, q, s] entered looks like this in reverse order[s, q, n, f, c, b, a]
and i can not use library classes to manipulate or search through arrays
/**
* This method reverses 'in place' the elements in
* the array. Reversing is defined as moving the
* elements in the array such that the first element
* becomes the last element, the second element
* becomes the second to last element, etc.
* <p>
here is what i have so far
Code:
public static void reverseOrder (Character[] symbols)
{
for(int reverse = (symbols.length - 1); reverse >= 0; reverse--)
{
Character c = symbols[reverse];
System.out.print(c);
}
}
Here is my tester class.
Code:
Character [] newlist = new Character[]{'a','b','c','f','n','q','s'};
System.out.println("");
System.out.print ("The array [");
separator = "";
for (Character s : newlist)
{
System.out.print(separator + s);
separator = ", ";
}
System.out.print ("] entered ");
ArrayExercises.reverseOrder(newlist);
System.out.print ("looks like this in reverse order[");
separator = "";
for (Character s : newlist)
{
System.out.print(separator + s);
separator = ", ";
}
System.out.print ("] ");
Which prints the result like this
The array [a, b, c, f, n, q, s] entered sqnfcbalooks like this in reverse order[a, b, c, f, n, q, s]
But it needs to print it like this.
The array [a, b, c, f, n, q, s] entered looks like this in reverse order[s, q, n, f, c, b, a]
and i can not use library classes to manipulate or search through arrays