Search code examples
javaarrayseclipsesystem.out

Java+Eclipse: Strange output when printing long arrays


I'm programming Java using Eclipse and I discovered a weird behavior of System.out.print when printing long arrays. Using the following code prints a long line of blanks before the actual output:

double[] values = new double[1000];
for (int i=0; i<1000; i++)
    values[i] = Math.random();
for (int i=0; i<1000; i++)
    System.out.print(values[i] + " ");

enter image description here

But when I change the array length to 100 it works as expected: enter image description here

Can someone explain this? Is it related to Java or to Eclipse?


Solution

  • Confirmed that its an Eclipse problem. Those are not blanks, they are actually values. If you copy those values, and paste in a text editor, you can see actual values. There were no problems when I used an online Java compiler(codingground.tutorialspoint.com)

    You can check this link for more info Eclipse console doesn't show the whole output