Here you can find the source of swap(int[] a, int i, int j)
public static void swap(int[] a, int i, int j)
//package com.java2s; //License from project: Open Source License public class Main { /** Swap ith element in a with jth element. */ public static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j];/*ww w . j a v a2 s .c o m*/ a[j] = temp; } /** Swap ith element in a with jth element. */ public static <T> void swap(T[] a, int i, int j) { T temp = a[i]; a[i] = a[j]; a[j] = temp; } private static void swap(Object i, Object j) { Object temp = i; i = j; j = temp; // i.setValue() would have worked. } }