I'm in my first Java programming class ever, and I am currently attempting to write up a user-made method that will loop through a boolean array, give me a random number, check if the array says the generated number is true or false, and then generate a different number if the array has an index of the generated number that states true (TL;DR: Find a random index in a boolean array, and rerun if the randomly-found number is true). My current dilemma is that if I use a do/while loop, the loop will never stop if all values of the array are true, and using a if/else will only rerun the number once. How do I fix this?
Aucun commentaire:
Enregistrer un commentaire