Here you can find the source of swap(List a, int i, int j)
private static <A> void swap(List<A> a, int i, int j)
//package com.java2s; import java.util.List; public class Main { private static <A> void swap(List<A> a, int i, int j) { final A tmp = a.get(i); a.set(i, a.get(j));// w ww . j a v a 2s . c o m a.set(j, tmp); } }