Here you can find the source of swap(List list, Object object1, Object object2)
Parameter | Description |
---|---|
list | a parameter |
object1 | a parameter |
object2 | a parameter |
@SuppressWarnings("unchecked") public static void swap(List list, Object object1, Object object2)
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt import java.util.List; public class Main { /**//from w ww . j a va2 s. co m * Swap object1 with object2 in the list. * * @param list * @param object1 * @param object2 */ @SuppressWarnings("unchecked") public static void swap(List list, Object object1, Object object2) { int indexObject1 = list.indexOf(object1); int indexObject2 = list.indexOf(object2); list.set(indexObject2, object1); list.set(indexObject1, object2); } }