Java Random Int random(int min, int max)

Here you can find the source of random(int min, int max)

Description

random

License

Open Source License

Declaration

private static int random(int min, int max) 

Method Source Code

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

public class Main {
    public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";

    private static int random(int min, int max) {
        return (int) (Math.random() * max + min);
    }/*ww  w.j a v a  2s  .  c om*/

    public static char random(String str) {
        return str.charAt(random(0, str.length()));
    }

    public static String random(int length) {
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; ++i)
            sb.append(random(ALPHABET));
        return sb.toString();
    }
}

Related

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