public class SwapTest
{
//all reference values can be changed
public static int[] Swap(int[] temp)
{
if( temp.length < 2 )
return null;
int t = temp[0];
temp[0] = temp[1];
temp[1] = t;
return temp;
}
public static void main(String args[])
{
int a = 2, b = 3;
int[] temp = new int[2];
temp[0] = a; temp[1] = b;
System.out.println( "a = " + a + " b = " + b );
int[] ret = Swap(temp);
a = temp[0];//a = ret[0]
b = temp[1];//b = ret[1]
System.out.println( "a = " + a + " b = " + b );
}
}