Java List Random Item getRandomIdxList(int minIdx, int maxIdx)

Here you can find the source of getRandomIdxList(int minIdx, int maxIdx)

Description

get Random Idx List

License

Open Source License

Parameter

Parameter Description
minIdx a parameter
maxIdx a parameter

Declaration

public static List<Integer> getRandomIdxList(int minIdx, int maxIdx) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**//from   w ww .jav  a2 s  .  c  o m
     *
     * @param minIdx
     * @param maxIdx
     * @return
     */
    public static List<Integer> getRandomIdxList(int minIdx, int maxIdx) {
        List<Integer> randomIdxList = new ArrayList<Integer>();
        for (int i = minIdx; i <= maxIdx; i++)
            randomIdxList.add(i);

        return randomIdxList;
    }

    /**
     *
     * @param maxIdx
     * @return
     */
    public static List<Integer> getRandomIdxList(int maxIdx) {
        return getRandomIdxList(0, maxIdx);
    }
}

Related

  1. generateInteger(int min, int maxInclusive, List excludedValues)
  2. getRandomElement(final List list)
  3. getRandomElement(List myList)
  4. getRandomElementFromList(List l)
  5. getRandomFromList(List list)
  6. getRandomIntBetween(int min, int max, List excludeList)
  7. listChooseOne(List list)
  8. makeListOfIntegersInRange(Integer size, Integer maxOfRange)
  9. makeRandomList(int arraySize, boolean unique)