Saturday, 3 September 2011

Random Number Generator in java


import java.util.Random;
class apples
{
public static void main(String args[])
{
Random dice=new Random();
int num;
for(int i=0;i<10;i++)        //this loop run 10times and generate 10
    //random numbers for a dice

{
num=1+dice.nextInt(6);
System.out.print(num+" ");
}
}
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.