I found this code, which reads some numbers as arguments and then assigns them as values in an array. I can't understand how java knows what the array length should be ?
public static void main(String[] args) {
int n = args.length;
int[] dataset = new int[n];
for (int i = 0; i < n; i++) {
dataset[i] = Integer.parseInt(args[i]);
}
System.out.println(java.util.Arrays.toString(dataset));
}
See Question&Answers more detail:os