Apache Commons Lang – RandomUtils
RandomUtilsクラスでは、ランダムな数値を生成するための機能が提供されています。
nextInt
public static int nextInt()
int型のランダムな数値を生成します。
- 戻り値:
- ランダムな数値
nextInt
public static int nextInt(java.util.Random random)
int型のランダムな数値を生成します。
- パラメータ:
random
– Randomインスタンス
- 戻り値:
- ランダムな数値
nextInt
public static int nextInt(int n)
0から指定した最大値の範囲で、int型のランダムな数値を生成します。
- パラメータ:
n
– 最大値(この値は戻り値に含まれません)
- 戻り値:
- ランダムな数値
nextInt
public static int nextInt(java.util.Random random, int n)
0から指定した最大値の範囲で、int型のランダムな数値を生成します。
- パラメータ:
random
– Randomインスタンス
n
– 最大値(この値は戻り値に含まれません)
- 戻り値:
- ランダムな数値
nextLong
public static long nextLong()
long型のランダムな数値を生成します。
- 戻り値:
- ランダムな数値
nextLong
public static long nextLong(java.util.Random random)
long型のランダムな数値を生成します。
- パラメータ:
random
– Randomインスタンス
- 戻り値:
- ランダムな数値
nextBoolean
public static boolean nextBoolean()
boolean型のランダムな値を生成します。
- 戻り値:
- ランダムな値
nextBoolean
public static boolean nextBoolean(java.util.Random random)
boolean型のランダムな値を生成します。
- パラメータ:
random
– Randomインスタンス
- 戻り値:
- ランダムな値
nextFloat
public static float nextFloat()
0.0から1.0の範囲で、float型のランダムな数値を生成します。
- 戻り値:
- ランダムな数値
nextFloat
public static float nextFloat(java.util.Random random)
0.0から1.0の範囲で、float型のランダムな数値を生成します。
- パラメータ:
random
– Randomインスタンス
- 戻り値:
- ランダムな数値
nextDouble
public static double nextDouble()
0.0から1.0の範囲で、double型のランダムな数値を生成します。
- 戻り値:
- ランダムな数値
nextDouble
public static double nextDouble(java.util.Random random)
0.0から1.0の範囲で、double型のランダムな数値を生成します。
- パラメータ:
random
– Randomインスタンス
- 戻り値:
- ランダムな数値
関連記事
- Apache Commons Lang – RandomStringUtils
- Apache Commons Lang – NumberUtils(Min / Max)
- Apache Commons Lang – NumberUtils(Compare / IsDigits / IsNumber)
- Apache Commons Lang – DateUtils(AddYears / AddMonths / AddWeeks / AddDays / AddHours / AddMinutes / AddSeconds / AddMilliseconds)
- Apache Commons Lang – DateUtils(SetYears / SetMonths / SetDays / SetHours / SetMinutes / SetSeconds / SetMilliseconds)
コメント 0