title: How to create an ArrayList with objects of another ArrayList?
body: <p>So I have an ArrayList "NamedShape" </p>
  
  <pre><code>ArrayList&lt;NamedShape&gt; shapes = new ArrayList&lt;NamedShape&gt;();
  </code></pre>
  
  <p>that contains a Shape and a String and what i want is to have another ArrayList "Connection" that will hold two fields but both are "NamedShape". My ArrayList "Connection" will then look like this:</p>
  
  <p><img src="https://i.stack.imgur.com/atPDo.png" alt="enter image description here"></p>
  
  <p>Here is my class for "NamedShape":</p>
  
  <pre><code>public class NamedShape {
      private String name;
      private Shape shape;
      public NamedShape( String name, Shape shape ){
          this.name = name;
          this.shape = shape;
      }
      public String getName(){
          return name; 
      }
      public Shape getShape(){ 
          return shape; 
      }
  }
  </code></pre>
  
  <p><strong>Here is my Connection class:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> public class Connection     {
      private NamedShape namedShape1;
      private NamedShape namedShape2;
      public Connection(??){
          ??
      }
     }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can you please help me to create this new ArrayList "Connection"? </p>