Java ThreadLocalRandom getRandomInt(int r)

Here you can find the source of getRandomInt(int r)

Description

Provide random numbers

License

Apache License

Parameter

Parameter Description
r - the upper bound (exclusive)

Return

a random int

Declaration

public static int getRandomInt(int r) 

Method Source Code

//package com.java2s;
/*/*  w  w  w.ja  va2s  . c  om*/
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

import java.util.concurrent.ThreadLocalRandom;

public class Main {
    /**
     * Provide random numbers
     *
     * @param r -
     *            the upper bound (exclusive)
     * @return a random <code>int</code>
     */
    public static int getRandomInt(int r) {
        return ThreadLocalRandom.current().nextInt(r);
    }
}

Related

  1. getRandomId(@Nonnull Random random, int length)
  2. getRandomInt()
  3. getRandomInt(int a, int b)
  4. getRandomInt(int limit)
  5. getRandomInt(int n)
  6. getRandomInteger()
  7. getRandomIntegerElement(List list)
  8. getRandomNumbers(Integer startNumber, Integer endNumber, Integer pageSize, Integer numNumbers)
  9. getRandomPassword()