I have this code. This code simply creates an array of size 1,000,000 to hold randomly generated integers. My problem is that i want to print 10 integers per line and the output is so strange and i don`t know why. I debugged the code and found that the code must work as expected. Though, it acts strangely. I will be grateful if anyone can help me. This is my code:
Integer[] list = new Integer[1000000];
for(int i = 0 ; i < list.length ; i++)
list[i] = (int)(Math.random() * 1000);
//print 10 integers per line
for(int i = 0 ; i < list.length ; i++){
if( (i+1) % 10 == 0)
System.out.printf("%-5d\n" , list[i]);
else
System.out.printf("%-5d" , list[i]);
}
I attach a screenshot of the output.

By the way: I use Intellij IDEA.