In java, every object is passed as reference to methods except primitive types like int, byte, Integer, Byte.(Sub. ed. Integer and Byte are also primitive type)
You could try to change the function to 'swap(int[] arr,int index1, index2)' and swap elements at specified indexes or you could pass objects to the method like swap(ObjectName a,ObjectName b) and swap objects' field values by something like :
Integer tmp = a.value;
a.value = b.value;
b.value = tmp;