Android examples for java.lang:Array Element
shuffle Array using Random
//package com.java2s; import java.util.Random; public class Main { public static int[] shuffleArray(int[] ar) { Random rnd = new Random(); for (int i = ar.length - 1; i > 0; i--) { int index = rnd.nextInt(i + 1); // Simple swap int a = ar[index]; ar[index] = ar[i];// www. j av a 2 s . co m ar[i] = a; } return ar; } }