Here you can find the source of swap(final Object[] array, int pos)
public static void swap(final Object[] array, int pos)
//package com.java2s; /*//www.j a v a 2s . co m * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. */ public class Main { public static void swap(final Object[] array, int pos) { swap(array, pos, pos + 1); } public static void swap(final Object[] array, int pos, boolean forward) { int pos2 = (forward) ? pos + 1 : pos - 1; swap(array, pos, pos2); } public static void swap(final Object[] array, int pos, int pos2) { if (pos == pos2) return; Object temp = array[pos]; array[pos] = array[pos2]; array[pos2] = temp; } public static void swap(final int[] array, int pos, int pos2) { if (pos == pos2) return; int temp = array[pos]; array[pos] = array[pos2]; array[pos2] = temp; } }