This is my code:
import java.util.List;
import java.util.ArrayList;
public static void main(String[] args){
List<Integer> possible = new ArrayList<Integer>();
for(int i=0; i<1000000; i++){
possible.add(i);
}
for(int i: possible){
System.out.println(i);
}
}
I expected the output to print values from 0 to 999,999 with spaces in between. However, my output is:
208
850209
850210
850211... all the way to 999999
Why is my for loop skipping hundreds of thousands of values? I tried replacing int with long
and double
. Both skip values when running. Any help? I am just trying to create an ArrayList
of values from 0 to 999,999.
Your program works fine. However the standard console will only display so many lines. So most of your output is getting cut off, making it appear that it is skipping thousands of numbers
Depending on what IDE you are using you should be able to change this. Go to console and change the console buffer size.
I use Eclipse so the way to change it in Eclipse is to go to window
then to preferences
and then under run/debug
there should be a console
section with the buffer size
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With