title: Code optimization for set of task with java
body: <p>i have some java code as below</p>
  
  <pre><code>Product prod1 = new Product("product A");
  List&lt;String&gt; prod1Patterns1 = List of("literal1", "literal2", "literal3"); //Just string literals which are specific to product A
  List&lt;String&gt; prod1Pattern2 =  List of("1", "2", "3"); // Just string literals which are specific to product A
  prod1.setprod1Patterns1(prod1Patterns1);
  prod1.setprod1Pattern2(prod1Pattern2);
  someotherfinalcollections.add(prod1); 
  </code></pre>
  
  <p>i have like 1000 products for which i have to use above code . Could some one please suggest me some generic way to do this . so that a common functionality could be written to iterate over some collections and do this 
  each product (out of 1000) has its own prodpatterns1 and prodpatterns2 </p>