Here you can find the source of swap(final T[] arr, final int i, final int j)
T
array.
Parameter | Description |
---|---|
T | The type of the array. |
arr | array |
i | position of first element |
j | position of second element |
public static <T> void swap(final T[] arr, final int i, final int j)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www. java2 s. c o m * Swaps two entries in a <code>T</code> array. * * @param <T> The type of the array. * @param arr array * @param i position of first element * @param j position of second element */ public static <T> void swap(final T[] arr, final int i, final int j) { final T temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } /** * Swaps two entries in a <code>double</code> array. * * @param arr array * @param i position of first element * @param j position of second element */ public static void swap(final double[] arr, final int i, final int j) { final double temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } }