Swapping the elements at the specified positions in the specified list. (If the specified positions are equal, invoking this method leaves the list unchanged.)

package collection.demos;

import java.util.ArrayList;
import java.util.Collections;


public class SwapingElementsInList {
    public static void main(String[] args) {
        ArrayList<String> activities=new ArrayList<String>();
        activities.add("analysis");
        activities.add("design");
        activities.add("development");
        activities.add("testing");
        activities.add("support");
        System.out.println("List : "+activities);
        Collections.swap(activities, 31);
        System.out.println("List after Swapped : "+activities);
    }
}

No comments:

Popular Posts