title: How to modify a value in list using iterator in java
body: <pre><code>    List firstList = new ArrayList();
      firstList.add("one");
      firstList.add("two");
      firstList.add("three");
  
  List secondList = new ArrayList();
      secondList.add("four");
      secondList.add("five");
      secondList.add("six");
  
      Iterator itr = firstList.listIterator();
      while(itr.hasNext()){
          String tempString1 = (String)itr.next();
          Iterator iter = secondList.listIterator();
          while(iter.hasNext()){
              String trmpString2 = (String)iter.next();
              tempString1 = trmpString2;
              break;
          }
          break;
      }
      System.out.println(firstList);
  </code></pre>
  
  <p>I want to replace the first object in first list with first object in secon list..,</p>
  
  <p>i.e i want out put as {four,two,three}.</p>
  
  <p>How to update the firstList with secondList values using iterator??</p>