Okay,I was writing my OS pracs exam..
I wrote a for loop for accepting n numbers and store them in int array 'a'.It should get n inputs from user and store them in array indices from 0 to n-1..
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(in.readLine());
}
Instead what happened is ...it stored the first value entered on index 0 and copied that value in all the indices of the array..
So for a input like : 42 57 98 100
the array stored :42 42 42 42
I was stuck. And got this error often since that day.
Similar problems happen ,though rarely, but these errors are so dangerous that you will not ever know why they occur and so you will not be able to correct it..
Solution:
Use System.out.println() in the for loop after each input.
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(in.readLine());
System.out.println();
}