title: iterate through ArrayList<T> java?
body: <p>I'm learning <code>Android</code> and <code>Java</code> i have created a class let's say like this </p>
  
  <pre><code> class x(){
      public int a; 
      public string b;
   }
  </code></pre>
  
  <p>and then i initiate a list of this class and then added values to its properties like this </p>
  
  <pre><code>public ArrayList&lt;x&gt; GetList(){
  
  List&lt;x&gt; myList = new ArrayList&lt;x&gt;();
  
      x myObject = new x();
      myObject.a = 1; 
      myObject.b = "val1";
       mylist.add(x);
  
      y myObject = new y();
      myObject.a = 2; 
      myObject.b = "val2";
       mylist.add(y);
  
  return myList;
  }
  </code></pre>
  
  <p><strong>My Question is how can i loop through what GetList() return</strong> </p>
  
  <p><em>i have tried</em> </p>
  
  <pre><code>ArrayList&lt;x&gt; list = GetList();
  Iterator&lt;x&gt; iterator = list.iterator();
  </code></pre>
  
  <p>but i don't know if this is the right way of doing this, plus i don't know what to do next i have added a breakpoint on the Iterator but it seemed to be null , the list have values thought </p>