So I Have this method
public int sumMathRandomAndSystemTime(){
n = 1 + ((int) (Math.random() * 10)+
(int) (System.currentTimeMillis() % 10));
if(n > 10){
sumMathRandomAndSystemTime();
}
System.out.println(n);
return n;
}
All I want is to print one random number (n) between 1 and 10 once. But for some reason, when I call the method it does print a random number, but some times only once, other times it prints the number like 10 times, 5 times, etc. Why is this happening?
Here's an example of my output
10
10
10
10
10