JavaGenerate a random number

import java.util.Random;
Random rand = new Random();
int randomNum = rand.nextInt((max - min) + 1) + min;

Related Snippets

Cover Image for Explain Inheritance in Java?

Explain Inheritance in Java?

Loading...
Cover Image for How does Exception Handling work in Java?

How does Exception Handling work in Java?

Loading...
Cover Image for What is a List in Java?

What is a List in Java?

Loading...
Cover Image for What is Method Overloading?

What is Method Overloading?

Loading...
Cover Image for What is the main method in Java?

What is the main method in Java?

Loading...
Cover Image for What is the Singleton Pattern?

What is the Singleton Pattern?

Loading...