title: how to add object collection List to another class object list
body: <p>The Stream in line three returns Collection(List) of . However, I am unable to store them directly in veggiesList. Can you help me with the best option</p>
  <pre><code>List&lt;VeggieDetails&gt; veggiesList = new ArrayList&lt;&gt;();
  veggiesWebelementlist = driver.findElements(By.xpath(&quot;//table//td[1]&quot;));
  veggiesList =veggiesWebelementlist.stream().map(e-&gt;getVeggieRow(e)).collect(Collectors.toList());   
  </code></pre>
  <p>private static Object getVeggieRow(WebElement e) {</p>
  <pre><code>    return new VeggieDetails(e.getText(), e.findElement(By.xpath(&quot;following-sibling::td[1]&quot;)).getText(),
              e.findElement(By.xpath(&quot;following-sibling::td[2]&quot;)).getText());
  }
          
  </code></pre>