I am currently having some trouble on one of my assignments. I want to use a scanner to read the input file and put each number in the file into a int array. I found an answer through How to read integer values from text file. But when I used this code it returned something weird. Below is my input, code, and output.
20401
11087
62176
70095
20947
20098
90914
53475
51251
20065
Scanner s = new Scanner(new File(fileName));
int[] list = new int[10];
int i = 0;
while(s.hasNextInt())
{
list[i] = s.nextInt();
i++;
}
s.close();
System.out.print(list);
The output is [I@42a57993. Can someone please explain what I might be doing wrong.
Soultion: System.out.println(Arrays.toString(list)); Returns it properly. Thanks