oneoderja
Sep 30, 2012, 07:28 PM
Define an integer array ‘arr’ with size 2 in the main method and initialize the two elements in ‘arr’ to be 1 and 2
Write a method ‘swap’ and pass the ‘arr’ into the method, swap two elements of the ‘arr’ in the method
Print out all elements in ‘arr’ in the main method
System.out.print(arr[0] + ‘ ‘ + arr[1]);
Swap(arr);
System.out.print(arr[0] + ‘ ‘ + arr[1]);
Write a method ‘swap’ and pass the ‘arr’ into the method, swap two elements of the ‘arr’ in the method
Print out all elements in ‘arr’ in the main method
System.out.print(arr[0] + ‘ ‘ + arr[1]);
Swap(arr);
System.out.print(arr[0] + ‘ ‘ + arr[1]);