Java - Need help to get random question from an array for my text based game #145247
Unanswered
DumbestPerson224
asked this question in
Programming Help
Replies: 1 comment
-
Since you're using the java.util.random library, you'll need to first initialize a Random object. Once you've done that, and assuming you are adding your questions to the You can use the nextInt method to pass in the length of your questions array, so that it returns a random integer between 0 and the length of your array. You can use this as a random index to pull a question, i.e. questions[randomIndex] I'm linking the docs here as well for you to read over yourself if you need any further information |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions