title: Analyzing arrays without known array size
body: <p>I've been searching around for an answer and I've always found things that have partially answered my issue. So, this is my code for now:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class VelikaDN {
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          System.out.println("Enter numbers: ");
          int[] array = new int[100];
          for (int i = 0; i &lt; array.length; i++) {
              array[i] = input.nextInt();
              // Number of elements
              int counter = 0;
              for (int j = 0; j &lt; array.length; j++) {
                  if (array[j] != 0)
                      counter++;
              }
              System.out.println("This array has " + counter + " numbers.");
          }
      }
  }
  </code></pre>
  
  <p>It works but at the end I've noticed something that wasn't so minor as I thought it was. This is the output: <a href="http://i.imgur.com/3mmEpUb.png" rel="nofollow">http://i.imgur.com/3mmEpUb.png</a>
  I've tried to reposition the print all over the code, tried to somehow stop the loop but I failed. I'm really not even sure anymore what is the issue. I tried to let go of this issue and do another task but as I've already said, anything outside the loop is not showing up.</p>
  
  <p>I'm sorry if this is confusing, I'm new at Java and I'm also pretty bad at explaining. If you have some tips or an alternate solution, feel free to just toss it in here. If there is something else I need to explain, then just say so.</p>