1 import java.util.Arrays;
2 public class Reverse
3 {
4
5 public static int[] reverse(int[] elements)
6 {
7 int temp;
8 // In the coming weeks, the lecturer will explain all of the code above. But for now here is an explanation:
9 // 1. In the code above we have provided an integer array "elements".
10 // 2. In the code above we have also provided another integer variable called "temp".
11 // In the space provided below, write code to reverse the order of values in the array "elements".
12 // Do NOT initialise "elements[0]" ... "elements[6]"
13 // Add your code BELOW this line. Do NOT change anything ABOVE this comment line.
14
15
16 return elements; //do NOT delete this line of code. Add your code right above it.
17
18 }
19 // do NOT change anything below this line
20 public static void main(String[] args) {
21 int[] elements = {1, 2, 3, 4, 5, 6, 7};
22 System.out.println("initially the array was: " + Arrays.toString(elements));
23 System.out.println("After calling reverse method, the array is: " + Arrays.toString(reverse(elements)));
24 }
25}