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);
  }
}
1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.