Here you can find the source of swap(Object[] arr, int i, int j)
private static void swap(Object[] arr, int i, int j)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { /**/*from ww w . jav a 2 s . com*/ * Swaps the two specified elements in the specified array. */ private static void swap(Object[] arr, int i, int j) { Object tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } @SuppressWarnings({ "rawtypes", "unchecked" }) public static void swap(List<?> list, int i, int j) { // instead of using a raw type here, it's possible to capture // the wildcard but it will require a call to a supplementary // private method final List l = list; l.set(i, l.set(j, l.get(i))); } }