Class RandomKit

java.lang.Object
com.iohao.net.common.kit.RandomKit

public class RandomKit extends Object
RandomKit
Author:
渔民小镇
date:
2022-07-14
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    random(int end)
    Gets a random number within the specified range (0 ~ end)
    int
    random(int start, int end)
    Gets a random number within the specified range
    long
    random(long end)
    Gets a random number within the specified range (0 ~ end)
    long
    random(long start, long end)
    Gets a random number within the specified range
    boolean
    Randomly generates a boolean value
    double
     
    int
    randomEle(int[] array)
     
    <T> T
    randomEle(@NonNull T[] array)
     
    <T> T
    randomEle(List<T> list)
     
    int
    randomInt(int limit)
    Gets a random number within the specified range [0, limit)
    int
    randomInt(int min, int max)
    Gets a random number within the specified range
    long
    randomLong(long limit)
    Gets a random number within the specified range [0, limit)
    long
    randomLong(long min, long max)
    Gets a random number within the specified range

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomKit

      public RandomKit()
  • Method Details

    • randomInt

      public int randomInt(int limit)
      Gets a random number within the specified range [0, limit)
      Parameters:
      limit - The limit of the random number range, exclusive.
      Returns:
      The random number.
    • randomInt

      public int randomInt(int min, int max)
      Gets a random number within the specified range
      Parameters:
      min - Minimum number (inclusive)
      max - Maximum number (exclusive)
      Returns:
      The random number
    • randomLong

      public long randomLong(long limit)
      Gets a random number within the specified range [0, limit)
      Parameters:
      limit - The limit of the random number range, exclusive.
      Returns:
      The random number
      Since:
      21.23
    • randomLong

      public long randomLong(long min, long max)
      Gets a random number within the specified range
      Parameters:
      min - Minimum number (inclusive)
      max - Maximum number (exclusive)
      Returns:
      The random number
      Since:
      21.23
    • random

      public int random(int start, int end)
      Gets a random number within the specified range
      Parameters:
      start - Starting value (inclusive)
      end - Ending value (inclusive)
      Returns:
      The random number
    • random

      public int random(int end)
      Gets a random number within the specified range (0 ~ end)
      Parameters:
      end - Ending value (inclusive)
      Returns:
      The random number
    • random

      public long random(long start, long end)
      Gets a random number within the specified range
      Parameters:
      start - Starting value (inclusive)
      end - Ending value (inclusive)
      Returns:
      The random number
      Since:
      21.23
    • random

      public long random(long end)
      Gets a random number within the specified range (0 ~ end)
      Parameters:
      end - Ending value (inclusive)
      Returns:
      The random number
      Since:
      21.23
    • randomBoolean

      public boolean randomBoolean()
      Randomly generates a boolean value
      Returns:
      The boolean value
    • randomEle

      public <T> T randomEle(List<T> list)
    • randomEle

      public <T> T randomEle(@NonNull T[] array)
    • randomEle

      public int randomEle(int[] array)
    • randomDouble

      public double randomDouble()