title: creating arrays within ArrayList java
body: <p>I'm trying to create two different types of Arrays within one ArrayList. Set up constructors accordingly (I think), but when it comes to instantiating them I get an error message "arr cannot be resolved". I'm slowly but surely going round the bend. How do I get the ArrayList to accept a simple array with doubles? (It also has to accept other types so it's not just a question of changing the ArrayList itself).Here's the code for the constructors &amp; main ArrayList:</p>
  
  <pre><code>class NumList implements Num
  {
      private ArrayList&lt;Num&gt; n1;
  
      public NumList( NumDouble[] doubleArray ) 
      {           
         n1 = new ArrayList&lt;Num&gt;();
         for( NumDouble d : doubleArray ) 
              n1.add( d );
      }
  
      public NumList(NumFloat[] floatArray ) 
      {
         n1 = new ArrayList&lt;Num&gt;();
         for( NumFloat d : floatArray ) 
              n1.add( d );
  
      }
  // methods of Num interface
  }
  </code></pre>
  
  <p>And my test class looks like this -</p>
  
  <pre><code>import java.util.ArrayList;
  
  public class Demo extends NumList {
      public Demo(NumDouble[] doubleArray) {  
          //suggested automatically to add super here
          super(doubleArray);
  
          double[] arr = {(1.1), (2.2), (3.3), (4.4)};
          ArrayList&lt;Num&gt; n1 = new ArrayList&lt;Num&gt;(arr);
      }
  
      public static void main (String [] args){
  
          arr.sqrt();
  
          System.out.println("The numbers sq are "+ arr [0]);
      }
  }
  </code></pre>
  
  <p>The NumList class has just three methods including sort. I have tried wildcards as well as </p>
  
  <p>It's probably something really easy ... any help appreciated.</p>