Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community of people that helps each other.

If you think you have some skills to help others

help someone and become a part of our community - List Q & A

Java - generate random number between 1 and 100

0 contributions
13 points

Generate random number between 1 and 100 in Java 

It can be accomplished with usage of

public static int nextInt(int min, int max) {
	return ThreadLocalRandom.current().nextInt(min, max);


System.out.println(nextInt(1, 100)); // 46
System.out.println(nextInt(1, 100)); // 65
System.out.println(nextInt(1, 100)); // 94
System.out.println(nextInt(1, 100)); // 18
System.out.println(nextInt(1, 100)); // 25

There are other ways to achieve it, look at this post:

and hashtag #random-min-max with methods for int, long, float, double to generate numbers in range min and max

0 contributions

Suggested wiki articles:

Suggested findings

Let's do the work and have some fun
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way. ❤ 💻 🙂
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    we will help you. 👍 ✔ 🦄
Read more