Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,894 questions

51,825 answers

573 users

How to generate 4 digits int random number in Java

1 Answer

0 votes
import java.util.concurrent.ThreadLocalRandom;

public class program {
    public static int random_min_max(int min, int max) {
        return ThreadLocalRandom.current().nextInt(min, max);
    }
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            System.out.println(random_min_max(1000, 10000));
        }
    }
}
 
 
/*
              
run:
 
9256
6366
3322
7117
8591
2340
4078
7681
4014
1993
     
*/

 

 



answered May 14, 2024 by avibootz

Related questions

1 answer 116 views
1 answer 137 views
1 answer 129 views
2 answers 941 views
1 answer 93 views
1 answer 114 views
1 answer 110 views
...