|
-
Oct 29th, 2002, 11:07 PM
#1
Thread Starter
Addicted Member
random number generation
How to generate random number in java?
-
Oct 30th, 2002, 12:06 AM
#2
Math.random()
Will generate a random number between 0 and 1.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 30th, 2002, 03:09 PM
#3
Hyperactive Member
Or you can instantiate an object of Random
import java.util.Random;
Random x = new Random();
x.nextInt(5); returns an int value [0,5)
-
Nov 1st, 2002, 12:19 AM
#4
Thread Starter
Addicted Member
but it gives error
impot java.util.Ramdom
class a
{
public static void main()
{
Random i=new Random();
}
}
-
Nov 1st, 2002, 01:04 PM
#5
Hyperactive Member
impot???
Ramdom???
I'm guessing you just typed that in the thread, so post the error you get. If you didn't, check your spelling 
Also thought you needed String[] args as input in the main procedure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|