public void swap(int[] a, int[] b)
{
int temp = a[0];
a[0] = b[0];
b[0] = temp;
}
Unfortunately, code that uses this swap method must know to package their variables into one element arrays before calling swap.
For example:
int[] x = new int[1];
int[] y = new int[1];
x[0] = 20;
y[0] = 15;
swap(x, y);
Last modified: Tue Aug 19 22:54:43 EDT