Skip to content

Commit e2005ab

Browse files
committed
RandomUtils#random()
1 parent e735e51 commit e2005ab

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/io/luna/util/RandomUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,18 @@ public static int random(Range<Integer> range) {
231231
return inclusive(low, high);
232232
}
233233

234+
/**
235+
* Returns a randomly chosen boolean value.
236+
* <p>
237+
* Each invocation uses {@link ThreadLocalRandom#current()} and produces either {@code true} or {@code false}
238+
* with equal probability.
239+
*
240+
* @return A random boolean value.
241+
*/
242+
public static boolean random() {
243+
return ThreadLocalRandom.current().nextBoolean();
244+
}
245+
234246
/* Shuffle overloads for all supported types. */
235247
public static <T> T[] shuffle(T[] array) {
236248
for (int i = array.length - 1; i > 0; i--) {

0 commit comments

Comments
 (0)