Here you can find the source of swap(int[] array, int i, int j)
public static void swap(int[] array, int i, int j)
//package com.java2s; public class Main { public static void swap(byte[] data, int pos1, int pos2) { byte tmp = data[pos1]; data[pos1] = data[pos2];//from w ww. j av a 2 s . c om data[pos2] = tmp; } public static void swap(short[] data, int pos1, int pos2) { short tmp = data[pos1]; data[pos1] = data[pos2]; data[pos2] = tmp; } public static void swap(int[] array, int i, int j) { if (i == j) return; int old = array[i]; array[i] = array[j]; array[j] = old; } }