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

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

Description

swap

License

Open Source License

Declaration

public static void swap(int[] array, int idx1, int idx2) 

Method Source Code

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

public class Main {
    public static void swap(int[] array, int idx1, int idx2) {
        if (idx1 != idx2) {
            array[idx1] = array[idx1] + array[idx2];
            array[idx2] = array[idx1] - array[idx2];
            array[idx1] = array[idx1] - array[idx2];
        }// ww w  . j a v  a2  s .c o m
    }
}

Related

  1. swap(int[] arr, int a, int b)
  2. swap(int[] arr, int a, int b, int c, int d, int key)
  3. swap(int[] arr, int i, int j)
  4. swap(int[] array)
  5. swap(int[] array, int i, int j)
  6. swap(int[] array, int index0, int index1)
  7. swap(int[] array, int x, int y)
  8. swap(int[] inArray, int index1, int index2)
  9. swap(int[] integers, int positionX, int positionY)