title: Java arraylists search and replace elements in each list
body: <p>I have lists in an arraylist, elements are recurrent in lists. I would like to search for a specified element and replace the second element after it in all the lists.</p>
  
  <pre><code>for (int lj = 0; lj &lt; arraynum; lj++) {
      for (int lk = 0; lk &lt; adjLists.get(lj).size(); lk+=3) {
          if (adjLists.get(lj).get(lk) == adjLists.get(l).get(h)
              &amp;&amp; adjLists.get(lj).get(lk + 1) == adjLists.get(l).get(h + 1)) {
              adjLists.get(lj).set(lk + 2, 1);
          }
      }
  }
  </code></pre>
  
  <p>Example - I search for 154 and 358, so zeros should be changed to 1:</p>
  
  <blockquote>
    <p>[288, 362, 0, 365, 85, 0, 137, 10, 0, 154, 358, 1]</p>
    
    <p>[285, 226, 0, 137, 10, 0, 20, 30, 1, 387, 297, 0, 154, 358, 1]</p>
  </blockquote>
  
  <p>This code do it only for one match, not for all matches.</p>