Java examples for Collection Framework:Array Index
swap array item by index
//package com.java2s; public class Main { public static <T extends Comparable<T>> void swap(T[] arr, int i, int j) { if (i != j) { T tmp = arr[i];/*w ww . j a v a 2s . c o m*/ arr[i] = arr[j]; arr[j] = tmp; } } }