Java Random Int randomInt(int n)

Here you can find the source of randomInt(int n)

Description

random Int

License

Apache License

Declaration

public static int randomInt(int n) 

Method Source Code

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

public class Main {
    public static int randomInt(int n) {
        return (int) (Math.random() * n);
    }/*from   w w  w .j  a va2s.  c o m*/

    public static int randomInt(int min, int max) {
        return randomInt(max + 1 - min) + min;
    }
}

Related

  1. randomInt(int fromInclusive, int toExclusive)
  2. randomInt(int in)
  3. randomInt(int low, int high)
  4. randomInt(int min, int max)
  5. randomInt(int mn, int mx)
  6. RandomInteger()
  7. randomInteger(final int upperRange)
  8. randomInteger(int low, int high)
  9. randomInteger(int min, int max)