Here you can find the source of swap(final int[] array, final int pos1, final int pos2)
Parameter | Description |
---|---|
array | array with element |
pos1 | index of first element |
pos2 | index of second element |
static void swap(final int[] array, final int pos1, final int pos2)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . j a v a 2 s.c o m * Swaps two elements in the array. * * @param array array with element * @param pos1 index of first element * @param pos2 index of second element */ static void swap(final int[] array, final int pos1, final int pos2) { final int temp = array[pos1]; array[pos1] = array[pos2]; array[pos2] = temp; } }