title: Need To Take Input To Array Until User Enters 0 JAVA
body: <p>I need help understanding how to write a for loop that takes in a certain amount of integers (must be 1 through 10) and it stops taking in numbers once 0 is entered (0 will be the last number). My code so far is:</p>
  
  <pre><code>   import java.util.Scanner;
     public class countNum {
  
        public static void main(String[] args) {
  
          int[] array;
  
          Scanner input = new Scanner(System.in);
          System.out.println ("Enter in numbers (1-10) enter 0 when finished:");
  
          int x = input.nextInt();
  
          while (x != 0) {
            if (x &gt; 2 &amp;&amp; x &lt; 10) {
            //Don't know what to put here to make array[] take in the values
            }
            else
            //Can I just put break? How do I get it to go back to the top of the while loop?
          }
        }   
  
       }
  </code></pre>
  
  <p>}</p>
  
  <p>I don't understand how to simultaneously initialize an array with a set length while having the Scanner read a certain amount of digits of that unknown length, until 0 is entered, and then the loop stops taking in input for the array.</p>
  
  <p>Thanks for any help!</p>