Java List Random Item makeListOfIntegersInRange(Integer size, Integer maxOfRange)

Here you can find the source of makeListOfIntegersInRange(Integer size, Integer maxOfRange)

Description

make List Of Integers In Range

License

Open Source License

Declaration

public static List<Integer> makeListOfIntegersInRange(Integer size, Integer maxOfRange) 

Method Source Code

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

import java.util.ArrayList;

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

public class Main {
    public static List<Integer> makeListOfIntegersInRange(Integer size, Integer maxOfRange) {

        List<Integer> returnVal = new ArrayList<>();
        Random random = new Random(27350);

        while (returnVal.size() < size) {

            Integer currentVal = random.nextInt(maxOfRange);

            if (!returnVal.contains(currentVal)) {
                returnVal.add(currentVal);
            }//ww w  .ja va2s.  c om
        }

        return returnVal;

    }
}

Related

  1. getRandomElementFromList(List l)
  2. getRandomFromList(List list)
  3. getRandomIdxList(int minIdx, int maxIdx)
  4. getRandomIntBetween(int min, int max, List excludeList)
  5. listChooseOne(List list)
  6. makeRandomList(int arraySize, boolean unique)
  7. newRandom(int size, int price, List oldRandomList)
  8. newRandomIntegerList(int size)
  9. newRandomStringList(int size, String... strings)