Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

generating random numbers close together

843785Mar 16 2009 — edited Mar 18 2009
You know how if you generate random numbers 1 after the other they are the same/very close? This is because it has to do with a clock right? Why doesn't my following code solve the problem? Is there any way I can make random numbers so they aren't all the same?
		for(int i = 0; i<level; i++)
		{
				arr[i] = (int)(Math.random()*10);
				Thread.sleep(400);
		}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 15 2009
Added on Mar 16 2009
20 comments
1,224 views