Java Random Int getRandomInt()

Here you can find the source of getRandomInt()

Description

int Random

License

Open Source License

Parameter

Parameter Description
length a parameter

Return

int

Declaration

public static int getRandomInt() 

Method Source Code


//package com.java2s;
import java.util.Random;

public class Main {
    /**//from   www .  j  a v  a2  s  . c o m
     * ThreadLocal Random Variables
     */
    private static final ThreadLocal<Random> random = new ThreadLocal<Random>() {
        protected Random initialValue() {
            return new Random();
        }
    };

    /**
     * int Random
     * @param length
     * @return int
     */
    public static int getRandomInt() {
        return random.get().nextInt(9990) + 1;
    }
}

Related

  1. getPositiveInt()
  2. getRandom(int c)
  3. getRandomInt()
  4. getRandomInt()
  5. getRandomInt()
  6. getRandomInt()
  7. getRandomInt()
  8. getRandomInt()
  9. getRandomInt(final int limit)