title: How to store an "infinite" number of integers in an ArrayList (Java)
body: <p>So I have a method that takes in numbers the user would like to input and stores them into an Array List. Right now I have the following method:</p>
  
  <pre><code>public static ArrayList&lt;Integer&gt; inputArrayList(){
  
      ArrayList&lt;Integer&gt; a = new ArrayList&lt;Integer&gt;();
      Scanner scan = new Scanner(System.in);
  
      int t;
      for(int i=0;i&lt;10000;i++){
          t = scan.nextInt();
          if(t!=0){
              a.add(t);                                                                                              
          }else{
              i+=200000;
          }
      }
      return a;
  }
  </code></pre>
  
  <p>I would like to improve it so that the method could technically take in an infinite number of values (not 10,000) because I feel like right now that while it would logically not be likely someone would put more values in than 10,000, I still feel the code as of now is sloppy. </p>
  
  <p>I also would like to be able to enter any number and have it be stored in the ArrayList as well, including the number 0 which currently acts as a sort of sentinel value. However, I can't think of another way to do so.</p>
  
  <p>Any help is greatly appreciated.</p>