Home » Random

Tag Archives: Random

How to Generate a Random Int in Java

This article shows how to generate a random Int or integer in Java using different approaches. 1. Introduction Java has several ways to generate a random Integer, primitive or wrapped object, on its environment. Here we’ll see some of these methods listed below: Random classMath classThreadLocalRandom class 2. Pre-requisites The minimum Java version for execute this article’s example is JDK ...

Read More »

java.util.concurrent.ThreadLocalRandom Example

In this example we shall show you how to make use of ThreadLocalRandom class, ThreadLocalRandom is a random number generator like its parent Random class. Like the global Random generator class, a ThreadLocalRandom is initialized with an internally generated seed that may not otherwise be modified.         1. ThreadLocalRandom Advantages ThreadLocalRandom provide more good performance and less overhead in ...

Read More »