Java Array Swap swap(T[] a, int idx1, int idx2)

Here you can find the source of swap(T[] a, int idx1, int idx2)

Description

Swaps two elements in an array.

License

Open Source License

Declaration

protected static <T> void swap(T[] a, int idx1, int idx2) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w  w  . j  a  v  a  2s.c  o  m*/
     * Swaps two elements in an array.
     */
    protected static <T> void swap(T[] a, int idx1, int idx2) {
        T tmp = a[idx1];
        a[idx1] = a[idx2];
        a[idx2] = tmp;
    }
}

Related

  1. swap(short x[], int[] y, int a, int b)
  2. swap(short x[], T[] a2, int a, int b)
  3. swap(short[] array, int indexA, int indexB)
  4. swap(String a[], int i, int j)
  5. swap(T[] a, int i1, int i2)
  6. swap(T[] arr, int a, int b)
  7. swap(T[] arr, int i, int j)
  8. swap(T[] arr, int index1, int index2)
  9. swap(T[] arr, int pos1, int pos2)