-
November 7th, 2010, 01:18 PM
#1
Array of random numbers ...
a little problem I have , well I have to make an array which generates 50 numbers from 0 to 999 which I can manage that the problem lies with the part were the numbers generatet cant be the same here is what ive done so far
[CODE]
import java.util.Random;
public class ArrayRandom{
public static void main(String args[]
{
Random r = new Random();
int temp;
int arr[] = new int[50];
for(int i = 0; i < 50; i++)
{
temp = r.nextInt(999) + 1; // this will give you a random number between 0 to 999.
arr[i] = temp; //here we know that the number is unique, so we can put it inside arr[i]
}
for(int i = 0; i < 50; i++)
{
System.out.print(arr[i] + " ");
}
}
}
[\CODE]
if some one could help me this would be a great help thanx shane : )
-
November 7th, 2010, 05:22 PM
#2
Re: Array of random numbers ...
-
November 7th, 2010, 06:11 PM
#3
Re: Array of random numbers ...
thanx to who has helped but i am having help elsewhere sorry for time wasting
Tags for this Thread
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
|