Here you can find the source of swap(int[] array, int x, int y)
public static void swap(int[] array, int x, int y)
//package com.java2s; //License from project: Apache License public class Main { /**//from www.j a v a 2 s .c o m * Swaps the given indices x with y in the array. */ public static void swap(int[] array, int x, int y) { int tmpIndex = array[x]; array[x] = array[y]; array[y] = tmpIndex; } /** * Swaps the given indices x with y in the array. */ public static void swap(long[] array, int x, int y) { long tmpIndex = array[x]; array[x] = array[y]; array[y] = tmpIndex; } /** * Swaps the given indices x with y in the array. */ public static void swap(double[] array, int x, int y) { double tmpIndex = array[x]; array[x] = array[y]; array[y] = tmpIndex; } /** * Swaps the given indices x with y in the array. */ public static void swap(boolean[] array, int x, int y) { boolean tmpIndex = array[x]; array[x] = array[y]; array[y] = tmpIndex; } /** * Swaps the given indices x with y in the array. */ public static <T> void swap(T[] array, int x, int y) { T tmpIndex = array[x]; array[x] = array[y]; array[y] = tmpIndex; } }