// 11/6/2019
// introduce partially fille arrays
// a partially filled array has 2 sizes associated with it:
// 1. capacity (how much space it has for elements) equals .length
// 2. actual number of elements
// when processing a partially filled array, loop
// for the number of elements, NOT:
// (a) until numbers.length
// (b) enhanced for loop

import java.util.Scanner;

public class SomeNumbers {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    final int SIZE = 500;
    int[] numbers = new int[SIZE]; // declares an array with SIZE ints
    int counter=0;
    System.out.println("Enter a #, ^D to exit:");
    while(sc.hasNextInt()  && counter < SIZE) {
      numbers[counter]=sc.nextInt();
      counter++;
      System.out.println("counter= " + counter);
      for (int i=0; i<counter; i++)
        System.out.print(numbers[i] + " ");
    }
    System.out.println(counter + " numbers were read in."
                         + " That is the # of elements in the array.");
  }
}