Java Random Int getRandomInt(int intStart, int intEnd)

Here you can find the source of getRandomInt(int intStart, int intEnd)

Description

get Random Int

License

Open Source License

Declaration

public static int getRandomInt(int intStart, int intEnd) 

Method Source Code


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

import java.util.Random;

public class Main {
    public static int getRandomInt(int intStart, int intEnd) {
        return (int) ((Math.random() * intEnd) + intStart);
    }//from w  ww .j  a v  a 2s .  c om

    public static int getRandomInt(Random rand, int intStart, int intEnd) {
        return intStart + rand.nextInt(intEnd - intStart + 1);
    }
}

Related

  1. getRandomInt(final int limit)
  2. getRandomInt(final int max)
  3. getRandomInt(final int maxValue)
  4. getRandomInt(final int min, final int max, final Random random)
  5. getRandomInt(int bound)
  6. getRandomInt(int lower, int upper)
  7. getRandomInt(int lower, int upper)
  8. getRandomInt(int max)
  9. getRandomInt(int max)