Java Random Int generateRandomIntObj(int range, int noOfElements)

Here you can find the source of generateRandomIntObj(int range, int noOfElements)

Description

generate Random Int Obj

License

Apache License

Declaration

public static Integer[] generateRandomIntObj(int range, int noOfElements) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {
    public static Integer[] generateRandomIntObj(int range, int noOfElements) {
        int arr[] = generateRandomInts(range, noOfElements);
        Integer generatedInts[] = new Integer[arr.length];
        for (int i = 0; i < arr.length; i++) {
            generatedInts[i] = arr[i];/* w ww  .j  a  v  a2s . co  m*/
        }
        return generatedInts;
    }

    public static int[] generateRandomInts(int range, int noOfElements) {
        Random randomGenerator = new Random();
        int generatedInts[] = new int[noOfElements];
        for (int i = 0; i < generatedInts.length; i++) {
            generatedInts[i] = randomGenerator.nextInt(range);
        }
        return generatedInts;
    }
}

Related

  1. generateRandomInteger(int aStart, int aEnd, Random aRandom)
  2. generateRandomInteger(int start, int end)
  3. generateRandomIntegerArray(int size, int min, int max)
  4. generateRandomIntegers(int numbersNeeded, int bound)
  5. generateRandomIntInRange(int min, int max)
  6. generateRandomInts(int range, int noOfElements)
  7. generateRandomIntUpto(int max)
  8. generateRandomIntValue()
  9. generateRandomNoInRange(int max, int min)