Android Array Randomize randomList(List options)

Here you can find the source of randomList(List options)

Description

random List

Declaration

public static List<String> randomList(List<String> options) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.List;
import java.util.Random;

public class Main {
    public static List<String> randomList(List<String> options) {
        int min = 1;
        int max = options.size();

        List<String> list = new ArrayList<String>(options);

        String temp2 = list.get(max - 1);
        list.remove(max - 1);/*from  w w  w .ja  va2s. c  om*/
        list.add(1, temp2);

        Random r = new Random();
        for (int i = 0; i < max; i++) {
            int rand = r.nextInt(max - min) + min;
            String temp = list.get(0);
            list.add(rand, temp);
            list.remove(0);
        }

        return list;
    }
}

Related

  1. getRandom(T... any)