en utilisant iOS Parfois, j'aime appeler 2 fonctions au hasard un bouton de presse par exemple, je voudrais utiliser; Alors parfois, l'utilisateur obtiendrait (1) l'autre fois (2), etc.arc4random équivalent pour Java?
if (arc4random() % 2 == 0) {
// Do one thing (1)
} else {
// Do something else(2)
}
}
Comment pourrais-je faire dans Eclipse/java? En d'autres termes, quelle est la même déclaration mais dans un langage Java?
Faire une recherche sur le Web pour "aléatoire Java" .... – nneonneo
duplication possible de [http://stackoverflow.com/questions/363681/...](http://stackoverflow.com/questions/363681/ generating-random-integers-in-a-range-with-java) et [http://stackoverflow.com/questions/901689/...](http://stackoverflow.com/questions/901689/java-generate -random-number-1-0-1) et tant d'autres. – alex