I have a simple app that generates facts. I would like to incorporate a function that generates a random fact instead of incrementing of decrementing.
My array looks lik
Simple! Method nextInt(facts.length) returns a random integer between 0 and the length of array. Put it as the index of the array to get the random one:
nextInt(facts.length)
Random rnd = new Random() String randomFact = facts[rnd.nextInt(facts.length)];