Reputation: 1418
package array;
import java.util.Scanner;
public class Array {
public static void main(String[] args) {
int n;
Scanner input = new Scanner(System.in);
n = input.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = input.nextInt();
}
System.out.println(a);
}
}
Upvotes: 0
Views: 45
Reputation: 7057
You cannot print an array directly, you have to iterate through it's values.
for (int j=0;j<a.length;j++){
System.out.println(a[j]);
}
Upvotes: 1