Java Array Swap swap(int[] inArray, int index1, int index2)

Here you can find the source of swap(int[] inArray, int index1, int index2)

Description

Swaps the positions index1 and index2 of inArray.

License

Eclipse Public License

Parameter

Parameter Description
inArray a parameter
index1 a parameter
index2 a parameter

Declaration

public static void swap(int[] inArray, int index1, int index2) 

Method Source Code

//package com.java2s;
/* ******************************************************************************
 * /*from ww w. j  av a  2 s.co  m*/
 * This file is part of JMH
 * 
 * License:
 *   EPL: http://www.eclipse.org/legal/epl-v10.html
 *   LGPL 3.0: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
 *   See the LICENSE file in the project's top-level directory for details.
 *
 * **************************************************************************** */

public class Main {
    /**
     * Swaps the positions index1 and index2 of inArray.
     * 
     * @param inArray
     * @param index1
     * @param index2
     */
    public static void swap(int[] inArray, int index1, int index2) {
        int temp = inArray[index1];
        inArray[index1] = inArray[index2];
        inArray[index2] = temp;
    }
}

Related

  1. swap(int[] array)
  2. swap(int[] array, int i, int j)
  3. swap(int[] array, int idx1, int idx2)
  4. swap(int[] array, int index0, int index1)
  5. swap(int[] array, int x, int y)
  6. swap(int[] integers, int positionX, int positionY)
  7. swap(int[] list, int i, int j)
  8. swap(long[] a, int i, int change)
  9. swap(long[] keys, double[] values, int i, int j)