Here you can find the source of swap(final Object[] data, final int i, final int j)
Parameter | Description |
---|---|
data | The data in which to exchange elements. |
i | The first element to exchange. |
j | The second element to exchange. |
public static void swap(final Object[] data, final int i, final int j)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w. j a v a 2 s .c o m*/ * Exchanges the elements at the two provided indices in the given array. * * @param data The data in which to exchange elements. * @param i The first element to exchange. * @param j The second element to exchange. */ public static void swap(final Object[] data, final int i, final int j) { /* Assume the indices are within the bounds of the array. */ final Object tmp = data[i]; data[i] = data[j]; data[j] = tmp; } }