swap method

void swap(
  1. int i,
  2. int j
)

Swaps elements at indices i and j in place.

Implementation

void swap(int i, int j) {
  final tmp = this[i];
  this[i] = this[j];
  this[j] = tmp;
}