Swaps the elements at the specified positions in the specified list. (If the specified positions are equal, invoking this method leaves the list unchanged.)
list | The list in which to swap elements. | |
i | the index of one element to be swapped. | |
j | the index of the other element to be swapped. |
IndexOutOfBoundsException | if either i or j
is out of range (i < 0 || i >= list.size()
|| j < 0 || j >= list.size()). |
Diagram: Collections