Java Array Swap swap(int arrs[], int i, int j)

Here you can find the source of swap(int arrs[], int i, int j)

Description

Swap method, It is used to intechange values into an array.

License

Open Source License

Parameter

Parameter Description
arrs The array
i the index of the first position to interchange
j the index of the second position to interchange

Declaration

public static void swap(int arrs[], int i, int j) 

Method Source Code

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

public class Main {
    /**/*from w ww  .ja v a 2 s  .  c  o m*/
     * Swap method, It is used to intechange values into an array.
     * 
     * @param arrs The array
     * @param i the index of the first position to interchange
     * @param j the index of the second position to interchange
     */
    public static void swap(int arrs[], int i, int j) {
        int temp = arrs[i];
        arrs[i] = arrs[j];
        arrs[j] = temp;
    }
}

Related

  1. swap(final String a[], final int i, final int j)
  2. swap(final T[] arr, final int i, final int j)
  3. swap(final T[] arr, final int i, final int j)
  4. swap(int arr[], int i, int j)
  5. swap(int array[], int first, int last)
  6. swap(int i, int j, Integer[] unsorted)
  7. swap(int i, int j, String[] index)
  8. swap(int keys[], int values[], int a, int b)
  9. swap(int[] a, int first, int second)