提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
交换ArrayList的元素
import java.util.ArrayList; import java.util.Collections; /* from 时代Java - N o w J a v a . c o m */ public class Main { public static void main(String[] args) { ArrayList arrayList = new ArrayList(); arrayList.add("A"); arrayList.add("B"); arrayList.add("C"); arrayList.add("D"); arrayList.add("E"); System.out.println("Before swaping, ArrayList contains : " + arrayList); /**来自 NowJava.com**/