Instead of writing:
Random randomGenerator = new Random();
for (int idx = 5; idx <= 15; ++idx){
int randomInt = randomGenerator.nextInt(1);
each time I need a random number in a function, Is it possible to just pass or call the result from a random number generator class into the function?
For Example, I have one function in particular which is receiving variables from another class
favoriteTracks(String fromExampleClass1, String fromExampleClass1again)
could I do
favoriteTracks(String fromExampleClass1, String fromExampleClass1again, Long fromRNGclass)
for clarification: My one function "favoriteTracks" requires variables passed from "ExampleClass1". At the same time, I want it to receive a random number as a variable (or call it, whichever is easiest). generated in another class by
public static long randomNum(){
Random randomGenerator = new Random();
for (int idx = 5; idx <= 15; ++idx){
int randomInt = randomGenerator.nextInt(1);
Aucun commentaire:
Enregistrer un commentaire