Honors Computer Science - Mrs. Bucaria

Array Review

Add the following methods to your ArrayReview Program

1)public static void printReverse(String[]s) This method will print s in reverse order.

2)public static String[] reverse(String[]s) This method will return a String[] that is the reverse order of s.

3)public static int[]slideRight(int[]s) Take the last element and put in first slot of the array and slide everything else to the right

4)public static int[]slideLeft(int[]s) Take take first element and put at the last slot of the array and slide everything else to the left

5)One or two other methods of your choice.


Main Program Test Code

1)System.out.println("output for printReverse"); printReverse(words); 2)System.out.println("\noutput for reverse words is now..");
words=reverse(words);
for(String s:words)
System.out.println(s);

3)System.out.println("\output for slideRight numbers before...");
int[]numbers={1,2,3,4,5};
System.out.println("\output for slideRight numbers before...");
for(int x:numbers)
System.out.println(x);
numbers=slideRight(numbers);
System.out.println("\output for slideRight numbers before...");
for(int x:numbers)
System.out.println(x);
//numbers should be {5,1,2,3,4}

4)int[]numbers2={10,9,8,7,6};
numbers2=slideLeft(numbers2);
//numbers2 should be {9,8,7,6,10}