Given an array, x of references to objects that implement the Comparable interface, two int variables k and j that contain valid indices to x, write some statements that exchange (or swap) the contents of the elements referenced by the integers.
LANGUAGE: JAVA
CHALLENGE:
Given an array, x of references to objects that implement the Comparable interface, two int variables k and j that contain valid indices to x, write some statements that exchange (or swap) the contents of the elements referenced by the integers.
SOLUTION:
Comparable temp; temp = x[k]; x[k] = x[j]; x[j] = temp;