title: Adding arrays to ArrayList
body: <p>I'm trying to produce a kind of lucky dip lotto number generator. At the moment, the code will produce the desired results but I'd really like to have the arrays in an arraylist. Here's my code so far:</p>
  
  <p>Ticket Class:</p>
  
  <pre><code>public class Ticket
  {
      private int numberOfLines;
  
      public void displayTicket(int numberOfLines)
      {
          Numbers numbersClass = new Numbers();
  
          System.out.println("***************************************");
          System.out.println("**                                   **");
          System.out.println("**           Lotto Ticket            **");
          System.out.println("**                                   **");
          System.out.println("***************************************");
          System.out.println("**                                   **");
  
          for(int i = 0; i &lt; numberOfLines; i++)
          {
              numbersClass.populateArray();
              numbersClass.ticket();
          }
  
          System.out.println("**                                   **");
          System.out.println("***************************************");
  
      }
  }
  </code></pre>
  
  <p>Numbers Class:</p>
  
  <pre><code>public class Numbers
  {
      // Fields
      private int[] numberLine;
      private int randomNumber;
      private Random randomGen;
  
  
      // Constructor : Initialise number array
      public Numbers()
      {
          numberLine = new int[6];
          randomNumber = 0;
          randomGen = new Random();
      }
  
      // Method : Generate 6 random numbers in a range 1 to 49
       public void populateArray()
      {
          List&lt;Integer&gt; pool = new ArrayList&lt;Integer&gt;();
          for (int i = 0; i &lt; 49; ++i)
          {
              pool.add(i + 1);
          }
          for (int i = 0; i &lt; 6; ++i)
          {
              randomNumber = randomGen.nextInt(pool.size());
              numberLine[i] = pool.get(randomNumber);
              pool.remove(randomNumber);
          }
      }
  
      // Method : Sort 6 numbers in ascending order  
      private int[] sortArray()
      {
          Arrays.sort(numberLine);
          return numberLine;
      }
  
      // Method : Format and display 6 numbers to the screen  
      public void ticket()
      {
          System.out.print("**         ");
          for (int i = 0; i &lt; numberLine.length; i++) 
          {
              if (numberLine[i] &lt; 10) 
              {
                  System.out.print(" ");
              }
              System.out.print(numberLine[i] + " ");
          }
          System.out.print("        **\n");
      }
   }
  </code></pre>
  
  <p>The Ticket class will get the numberOfLines from the user at runtime, then print out the first half of the lotto ticket and then use the Numbers class to generate and print the random numbers, format them, then print them to the screen and finally print the bottom of the ticket.</p>
  
  <p>What I should do really, is have the arrays from the Numbers class be stored into an arraylist in the Ticket class and then format the lines and print them from the Ticket Class.</p>
  
  <p>Question 1: How would I go about adding the random number lines (the arrays) into an arraylist in the Ticket class?</p>
  
  <p>Question 2: How would I format the lines if they are in an arraylist?</p>