title: How to Access Indices of ArrayList Inside Another ArrayList?
body: <p>I'm working on an recursive programming assignment, and I'm trying to find out how to loop and get values of an ArrayList inside of a bigger ArrayList. I found that others have asked this question before, but it is still not very clear how this can be done precisely. </p>
  
  <p>Here is an example of what I'm trying to do: </p>
  
  <pre><code>import java.util.*;
  
  public class Test{
  
  public static void main(String[] args) {
  
      ArrayList&lt;String&gt; Array1 = new ArrayList&lt;String&gt;();
  
      // Array 1: [0][1][0][0][1]
  
      Array1.add("0");
      Array1.add("1");
      Array1.add("0");
      Array1.add("0");
      Array1.add("1");
  
      ArrayList&lt;String&gt; Array2 = new ArrayList&lt;String&gt;();
  
      // Array 2: [1][0][0][1][0]
  
      Array2.add("1");
      Array2.add("0");
      Array2.add("0");
      Array2.add("1");
      Array2.add("0");
  
      ArrayList&lt;ArrayList&lt;String&gt;&gt; Array3 = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
  
      // Array 3: [Array1][Array2]
  
      Array3.add(Array1);
      Array3.add(Array2);
  
  // Now Find every indices or occurrences in Array2 where value is "1"
  
      for (ArrayList&lt;String&gt; Outer : Array3) {
          for (String inner : Outer) {
              if (str.equals("1")) {
                  // Get all indices where "1" is found inside Array2 ?
  
              }
           }
        }
     }
  }
  </code></pre>
  
  <p>So I have Array3 that stores <strong>Array1</strong> and <strong>Array2</strong>, and what I want to do is loop through Array3, find Array2 and indices in Array2 where value is "1".</p>
  
  <p>The problem with the loop in in this code is that it loops through all values in Array1 and Array2 whereas I'm just trying to find the values inside Array2. </p>