1

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);
  }
}
Roman Racca
  • 37
  • 1
  • 6
  • 1
    Try increasing Eclipse console buffer: http://stackoverflow.com/questions/2828255/how-do-i-increase-the-capacity-of-the-eclipse-output-console – aioobe Nov 30 '14 at 20:50

1 Answers1

1

Yes, eclipse has a character limit on the console, but you can expand it or cancel the limit altogether.

In Eclipse's preferences, go to Run/Debug, then to Console. You see a checkbox "Limit console output". You can uncheck it, or you can change the Console buffer size.

I'm referring to Eclipse Luna.

RealSkeptic
  • 33,993
  • 7
  • 53
  • 79