Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Help :O

Name: ipoopmypants !49.zlWoq9M 2009-11-24 22:53

Anyone know how in Java I check check an array to see if there are any duplicates?

        int[] random = new int[100];
        Random randomGenerator = new Random();
        boolean inArray = true;

for(int i = 0; i < random.length; i++)
        {
            random[i] = randomGenerator.nextInt(999);
            if(random[i] == /*CHECK ALL OTHER INDEXES IN THE ARRAY*/)
            {
                random[i]++;
            }
           
            }

Name: ipoopmypants !0bsNHTKXw2 2009-11-25 1:01

>>5

It's for an assignment.

Basically I have to generate 100 random numbers in a 10x10 grid. The numbers have to be in an array, ranging from 0-999. However, none of the numbers may be duplicates.

I see what you're doing there, but It's still generating duplicates of numbers.

I'm only a beginner at Java so any help would be grateful

Here's the rest of my code, sorry for the lack of comments

http://demsix.pastebin.com/d565ed2b7

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List