All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.litongjava.tio.utils.hutool.RandomUtils Maven / Gradle / Ivy

There is a newer version: 3.7.3.v202400213-RELEASE
Show newest version
package com.litongjava.tio.utils.hutool;

import java.util.Random;

public class RandomUtils {

  public static int nextInt(int min, int max) {
    Random random = new Random();
    // nextInt(max - min + 1) 生成0到(max - min)之间的随机数,然后加上min以便生成1到max之间的随机数
    int randomNumber = random.nextInt(max - min + 1) + min;
    return randomNumber;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy