title: Using an ArrayList as Parameter of Constructor
body: <p>I'm trying to write a constructor for a class which accepts an ArrayList (containing integers) as one of it's arguments.  When instantiating this class later, I will pass an appropriate, pre-populated list of values, so I don't want to create an empty list inside the constructor.</p>
  
  <p>Unfortunately, when I try to compile the below code, Java spits out five errors, all related to line 23 (my constructor's function definition).  Any advice would be appreciated:</p>
  
  <pre><code>/*
   * SumGenerator
   * 
   * @author James Scholes
  */
  
  import java.util.ArrayList;
  import java.util.Random;
  
  public class SumGenerator
  {
      // Some initial variables
      public int timesTable;
      public int multiple;
  
      /*
       * Constructor
       * 
       * @param timesTable(int): The times table to use for sum generation
       * @param limit(int): The highest multiple to use in sum generation
       * @param previousMultiples(ArrayList&lt;Integer&gt;): The previously used multiples to avoid sum duplication
      */
      public SumGenerator(int timesTable, int limit = 10, ArrayList&lt;Integer&gt; previousMultiples)
      {
          this.timesTable = timesTable;
          Random randomGenerator = new Random();
  
          // Create a list to store our multiples
          ArrayList&lt;Integer&gt; multiples = new ArrayList&lt;Integer&gt;();
          // and add our multiples to it, only if 
          // they haven't been used before
          for(int i = timesTable; i &lt;= limit; i++)
          {
              if(previousMultiples.contains(i))
              {
                  continue;
              }
              else
              {
                  multiples.add(i);
              }
          }
  
          this.multiple = multiples.get(randomGenerator.nextInt(multiples.size()));
      }
  
  }
  
  SumGenerator.java:23: error: ')' expected
      public SumGenerator(int timesTable, int limit = 10, ArrayList&lt;Integer&gt; previousMultiples)
                                                   ^
  SumGenerator.java:23: error: illegal start of type
      public SumGenerator(int timesTable, int limit = 10, ArrayList&lt;Integer&gt; previousMultiples)
                                                      ^
  SumGenerator.java:23: error: &lt;identifier&gt; expected
      public SumGenerator(int timesTable, int limit = 10, ArrayList&lt;Integer&gt; previousMultiples)
                                                        ^
  SumGenerator.java:23: error: ';' expected
      public SumGenerator(int timesTable, int limit = 10, ArrayList&lt;Integer&gt; previousMultiples)
                                                         ^
  SumGenerator.java:23: error: &lt;identifier&gt; expected
      public SumGenerator(int timesTable, int limit = 10, ArrayList&lt;Integer&gt; previousMultiples)
                                                                                              ^
  5 errors
  </code></pre>