Java Array Swap swapArray(int[] v, int i, int j)

Here you can find the source of swapArray(int[] v, int i, int j)

Description

Swap elements in list

License

LGPL

Parameter

Parameter Description
v list
i index first element
j index second element

Declaration

public static void swapArray(int[] v, int i, int j) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**//from ww  w  .  j  a v  a  2s .  co  m
     * Swap elements in list
     *
     * @param v list
     * @param i index first element
     * @param j index second element
     */
    public static void swapArray(int[] v, int i, int j) {
        int t = v[i];

        v[i] = v[j];
        v[j] = t;
    }
}

Related

  1. swap2(double v[], int v2[], int i, int j)
  2. swap2Bytes(byte[] bytes, int offset)
  3. swap3(String[] a, int x, int y, int z)
  4. swapAll(final Object[] array)
  5. swapAndPrint(int[] arr, int m, int n)
  6. swapArrayStr(String[] arr)
  7. swapArrayValues(int i1, int i2, int[] indices)
  8. swapBlocks(byte[] array, int fromA, int toA, int fromB, int toB)
  9. swapByteArray(byte[] source)