mercredi 27 janvier 2021

How to fill an Array with random numbers and search through them [closed]

Im working on an assignment where we have to fill an array with random numbers then search through the array to see if a certain number exists, all of it works except whenever I run it, it says the number im looking for is In the array 10,000 times (which is how many numbers I fill the array with)

public class MethodResource {
        
    public static void fillTheArray(int[] iTempArray, int SIZE) {
        // Finished - Don't alter!
        final int RANGE = 2500;
        Random rand = new Random();
    
        for (int index = 0; index <= SIZE - 1; index++){
            iTempArray[index] = rand.nextInt(RANGE);
        }
    }//end of fillTheArray



Aucun commentaire:

Enregistrer un commentaire