Here you can find the source of swap(ArrayList
public static void swap(ArrayList<Integer> numbers, int i, int j)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static void swap(int[] numbers, int i, int j) { int temp = numbers[i]; numbers[i] = numbers[j];//from w ww .ja v a2 s .c o m numbers[j] = temp; } public static void swap(ArrayList<Integer> numbers, int i, int j) { int temp = numbers.get(i); numbers.set(i, numbers.get(j)); numbers.set(j, temp); } public static void swap(ArrayList<Integer>[] numbers, int i, int j) { ArrayList<Integer> temp = numbers[i]; numbers[i] = numbers[j]; numbers[j] = temp; } }