Java Random Int random(int maxValue)

Here you can find the source of random(int maxValue)

Description

random

License

Open Source License

Declaration

public static int random(int maxValue) 

Method Source Code

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

public class Main {
    public static int random(int maxValue) {
        return (int) (Math.random() * (maxValue + 1));
    }//w  ww .  j a v a 2  s. c om

    public static float random(float maxValue) {
        return (float) (Math.random() * maxValue);
    }

    public static double random(double maxValue) {
        return Math.random() * maxValue;
    }

    public static int random(int minValue, int maxValue) {
        return (int) (Math.random() * (maxValue - minValue + 1)) + minValue;
    }

    public static float random(float minValue, float maxValue) {
        return (float) (Math.random() * (maxValue - minValue)) + minValue;
    }

    public static double random(double minValue, double maxValue) {
        return Math.random() * (maxValue - minValue) + maxValue;
    }
}

Related

  1. random(int length, String data)
  2. random(int limit)
  3. random(int lo, int hi)
  4. Random(int low, int high)
  5. random(int lowerBound, int upperBound)
  6. random(int min, int max)
  7. random(int min, int max)
  8. random(int min, int max)
  9. random(int min, int max)