I have this code that if it does is generate random numbers in a range that I choose. The problem I have is that if they see the line of for, I supposedly have to generate 10000 random numbers, but this only makes me 6668. If I put a less than that amount, the code works fine. What's going on? Eclipse has some sort of character limit? Thank you very much!
Greetings!
import java.util.Random;
public static final void main(String... aArgs){
log("Generating random integers in the range 1..10.");
int START = 2000000 ;
int END = 8999999 ;
Random random = new Random();
for (int idx = 1; idx <= 10000; ++idx){
showRandomInteger(START, END, random);
}
log("Done.");
}
private static void showRandomInteger(int aStart, int aEnd, Random aRandom){
if (aStart > aEnd) {
throw new IllegalArgumentException("Start cannot exceed End.");
}
//get the range, casting to long to avoid overflow problems
long range = (long)aEnd - (long)aStart + 1;
// compute a fraction of the range, 0 <= frac < range
long fraction = (long)(range * aRandom.nextDouble());
int randomNumber = (int)(fraction + aStart);
log("351" + randomNumber);
}
private static void log(String aMessage){
System.out.println(aMessage);
}
}