How can I generate random integers in a specific range with Java?
Learn how to limit your random number generation to a specific range while using java.util.Random, Math.random, and ThreadLocalRandom.
Programmers often need to generate random numbers, be it for a dice roll, choosing a random ID, or picking a sample value for testing purposes. In this tutorial Brian Gorman outlines three common approaches to random number generation and explains when each will prove most useful. After watching this video, Java beginners will be able to add java.util.Random, Math.random, and ThreadLocalRandom to their repertoire and limit their output to a specific range. Brian will take you step-by-step through each method, demonstrating the expected output of each process.
Brian L. Gorman is an experienced .NET developer, certified as an MCSD in C# .NET. Holding a Masters of Science in computer information systems, he has many years of experience instructing college-level SQL database, C#, VB.NET, Java, and Microsoft Office courses. Brian has also authored a number of full technical video courses on these subjects.