title: How to dynamically declare variables in a loop?
body: <p>I'm trying to make a program in which an object is declared every time a loop is passed through.</p>
  
  <pre><code>package sequence;
  
  public class SequenceServer {
      SequenceObj sequence = new SequenceObj();
      public void findSequence(int[] sequence, int lastNumber) {
          for(int i = 0; i &lt; sequence.length; i++) {
              SequenceObj sequenceTemp = new SequenceObj(); // this line is wrong, but I don't know how to make it work
          }
      }
  }
  </code></pre>
  
  <p>There are no errors, but I need to make it so a potentially infinite number of variables can be declared through the user interacting with the program, as opposed to me individually declaring all of the variables.</p>