I have to read from an external file, a list of numbers and insert them into their own array for being positive or negative. The scanner reads the numbers just fine, but when it inserts them into an array is where it goes wrong. As you can see below is my code, and the output. What is in the file is printed in the output, but when I ask it to print the arrays, it's that jumbled mess of letters/numbers/symbols. Can anyone help me fix it?
public class Numbers {
public static void main(String[] args) throws IOException {
Scanner reader = new Scanner(new FileInputStream("First.dat"));
int Positive[] = new int[20];
int Negative[] = new int[20];
int X = 0;
int Y = 0;
while (reader.hasNextInt()) {
int Start = reader.nextInt();
System.out.println(Start);
if (Start < 0) {
Negative[X] = Start;
X += 1;
}
if (Start > 0) {
Positive[Y] = Start;
Y += 1;
}
}
System.out.println(Positive + " " + Negative);
}
}
Output:
3
66
54
-8
22
-16
-56
19
21
34
-34
-22
-55
-3
-55
-76
64
55
9
39
54
33
-45
[I@1b41650 [I@24e11c