yes, you need to do:
public static void swap(boolean[] arr, int x, int z){
writeln("swapping");
boolean temp = arr[x];
arr[x]=arr[z];
arr[z]=temp;
}
because when you send position[a]
and position[b]
java will copy their value to a new parameter, and so when you leave the swap
function, no change was done to the variables
to understand more you can read on pass-by-value and pass-by-ref in java here
When the method or constructor is invoked, the values of the
actual argument expressions initialize newly created parameter
variables, each of the declared Type, before execution of the body of
the method or constructor. The Identifier that appears in the
DeclaratorId may be used as a simple name in the body of the method or
constructor to refer to the formal parameter.