Wednesday 28 August 2013

Avoid generating random integer in different functions

Avoid generating random integer in different functions

My function:
public int[] generateRandomInteger(){
int[] arr = new int[100];
Random randomGenerator = new Random();
for (int i = 0; i < 100; i++){
int randomInt = randomGenerator.nextInt(16) + 10;
arr[i] = randomInt;
}
return arr;
}
The problem is: when I use arr in another function, it will generate a
different array of 100 integer numbers. How can I avoid this problem ? I
only want to use exactly the array that generate from the function above.
Any help would be appriciated !

No comments:

Post a Comment