Logo

Programming-Idioms

Swap the elements at indices i, j in the list items
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
items[i], items[j] = items[j], items[i]
items.swap(i, j)
import static java.util.Collections.swap;
swap(items, i, j);
classes
items.exchange(i,j);
items[i], items[j] = items[j], items[i]
items[i], items[j] = items[j], items[i]
items.swap(i, j);