title: Iterator is not working
body: <p>I was trying to write an iterator for a program of mine, but it seems it is not iterating as it should. I tried to follow an example from online but still. </p>
  
  <pre><code>public Iterator&lt;ParkingPlace&gt; iterator(){
  
      Iterator&lt;ParkingPlace&gt; iterator = new Iterator&lt;ParkingPlace&gt;() {
          int currentIndex =0;
  
          @Override
          public boolean hasNext() {
              return currentIndex&lt;parking.size() &amp;&amp; parking.get(currentIndex)!=null;
          }
  
          @Override
          public Parking next() {
              if(!hasNext()){
                  throw new NoSuchElementException();
              }else if (hasNext()){
                  return parking.get(currentIndex++);
              }
              return null;
          }
      };
      return iterator;
  }  
  </code></pre>
  
  <p>Where parking is a List of "parking places" defined as </p>
  
  <blockquote>
    <p>List &lt; ParkingPlace> parking = new ArrayList();</p>
  </blockquote>
  
  <p>So, the last part where I define parking is correct, I have checked it and it has all the expected elements.  </p>
  
  <p>But my iterator is not giving me back what I expect from him.<br>
  My main function:  </p>
  
  <pre><code>public static void main(String[] args) {
      Parking parking = new Parking();
  
      //Tests for iterator
      for (ParkingPlace place : parking) {
          System.out.println(parking.iterator());
      }
  
  }
  </code></pre>
  
  <p>Ex. of results:<br>
  Parking$1@61bbe9ba<br>
  Parking$1@610455d6<br>
  Parking$1@511d50c0  </p>
  
  <p>Expected results would be:<br>
  A0<br>
  A1<br>
  A2   </p>
  
  <p>Ideas where my mistake could be?</p>