Here you can find the source of swap(ArrayList
public static void swap(ArrayList<String> dataStrs, int i, int j)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static void swap(ArrayList<String> dataStrs, int i, int j) { String temp = dataStrs.get(i); dataStrs.set(i, dataStrs.get(j)); dataStrs.set(j, temp);//from ww w . j a v a 2s . c om } }