Running this program shows the wrong output. My file "values.txt" contains 45678 and the output
after running the program is 00000.
import java.util.Scanner;
public class array{
public static void main(String[] args)throws IOException
{
final int SIZE = 6;
int[] numbers = new int[SIZE];
int index = 0;
File fl = new File("values.txt");
Scanner ab = new Scanner(fl);
while(ab.hasNext() && index < numbers.length)
{
numbers[index] = ab.nextInt();
index++;
System.out.println(numbers[index]);
}
ab.close();
}
}