title: About Iterator and Iterable interface constructors
body: <p>Please help me to understand below:</p>
  
  <p>Since <code>Iterable</code> and <code>Iterator</code> are interfaces so coding <code>Iterator&lt;T&gt; it = new Iterator&lt;T&gt; ();</code> will get <code>error(interface has no constructor ?)</code>. </p>
  
  <p>But why the codes below work OK? <code>new Iterable&lt;String&gt; () { --- }</code> and its nesting <code>new Iterator&lt;String&gt;()</code> are both constructors of interfaces <code>Iterable</code> and <code>Iterator</code>, just they return the anonymous objects vs. "it" the real object.</p>
  
  <pre><code>public class MultiIterableClass extends IterableClass {
      public Iterable&lt;String&gt; reversed() { 
          return new Iterable&lt;String&gt;() {
              public Iterator&lt;String&gt; iterator() { 
                  return new Iterator&lt;String&gt;() { 
                      int current = words.length -1;
  
                      public boolean hasNext() { return current &gt; -1; }
                      public String next() { return words[current--]; }
                      public void remove() { // Not implemented
                          throw new UnsupportedOperationException();
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>The 2nd question is that the above codes(from Thinking in Java 4th-Ed) are complicated with constructor nesting another constructor, what are the <code>reversed()</code> return ? Return an <code>Iterable-object</code> or return <code>Iterator-object</code> or both? If both what is the return order? </p>
  
  <p>Thanks</p>
  
  <p>ZW</p>