Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Kaua Costa   on Feb 21 In Java Category.

  
Question Answered By: Lurline Fischer   on Feb 21

Try this code to check or test your random  number generator.


public static void main(String[] arg) {
Random rand = new Random();
long t = 0;
long total=0;
for (int k = 0; k < 10; k++) {
t=0;
for (int i = 0; i < 100; i++) {
i = rand.nextInt(100);
System.out.println(i);
t++;
}
total=total+t;
System.out.println("instances:" + t);
}
System.out.println("total instances:" + total);
}

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Problem with random number in java Or get search suggestion and latest updates.


Tagged: