1 16 package org.apache.commons.lang.math; 17 18 import java.util.Random ; 19 20 30 public class RandomUtils { 31 32 35 public static final Random JVM_RANDOM = new JVMRandom(); 36 37 42 48 public static int nextInt() { 49 return nextInt(JVM_RANDOM); 50 } 51 52 59 public static int nextInt(Random random) { 60 return random.nextInt(); 61 } 62 63 71 public static int nextInt(int n) { 72 return nextInt(JVM_RANDOM, n); 73 } 74 75 84 public static int nextInt(Random random, int n) { 85 return random.nextInt(n); 87 } 88 89 95 public static long nextLong() { 96 return nextLong(JVM_RANDOM); 97 } 98 99 106 public static long nextLong(Random random) { 107 return random.nextLong(); 108 } 109 110 116 public static boolean nextBoolean() { 117 return nextBoolean(JVM_RANDOM); 118 } 119 120 127 public static boolean nextBoolean(Random random) { 128 return random.nextBoolean(); 129 } 130 131 138 public static float nextFloat() { 139 return nextFloat(JVM_RANDOM); 140 } 141 142 150 public static float nextFloat(Random random) { 151 return random.nextFloat(); 152 } 153 154 161 public static double nextDouble() { 162 return nextDouble(JVM_RANDOM); 163 } 164 165 173 public static double nextDouble(Random random) { 174 return random.nextDouble(); 175 } 176 177 } 178 | Popular Tags |