Java List Swap swap(List list, int i, int j)

Here you can find the source of swap(List list, int i, int j)

Description

Swaps the values in the list at the given positions

License

Open Source License

Parameter

Parameter Description
list the list to perform the swap in
i the first position to swap
j the second position to swap

Declaration

public static void swap(List list, int i, int j) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /**/*from   ww w. j  a  v  a 2 s .  c om*/
     * Swaps the values in the list at the given positions
     * @param list the list to perform the swap in
     * @param i the first position to swap
     * @param j the second position to swap
     */
    public static void swap(List list, int i, int j) {
        Object tmp = list.get(i);
        list.set(i, list.get(j));
        list.set(j, tmp);
    }
}

Related

  1. swap(final L list1, final L list2, final int index)
  2. swap(final List list, final int index0, final int index1)
  3. swap(final List list, final int index1, final int index2)
  4. swap(final List list, int i1, int i2)
  5. swap(List list, Object object1, Object object2)
  6. swap(List a, int i, int j)
  7. swap(List items, int index1_, int index2_)
  8. swap(List list, int i1, int i2)