Obtendo um valor aleatório de uma matriz
Eu tenho um aplicativo simples que gera fatos. Eu gostaria de incorporar uma função que gera um fato aleatório em vez de incrementar a decrementar.
Minha matriz fica assim.
public class Facts {
String facts[] = {
"Elephants are the only mammals that can't jump.",
"Candles will burn longer and drip less if they are placed in the freezer a few hours before using.",
"Potatoes have more chromosomes than humans.",
"You burn more calories sleeping than you do watching television.",
"Animals that lay eggs don't have belly buttons.",
};
String factNumber[] = {
"Fact 1",
"Fact 2",
"Fact 3",
"Fact 4",
"Fact 5",
};
public String randomButton() {
Random r = new Random();
return facts[i]
}