Create object of anonymous class

Viewed 731

We have inner class

class OuterClass
{
  public Iterator getIterator(final String name)
  {
    class LocalIterator implements Iterator
    {
        public Iterator next()
        {
            return new LocalIterator();
        }
    }
    return new LocalIterator();
 }
}

Is it possible to make an anonymous class with all functionality of Local iterator and make getIterator return object of that anonymous class? The main problem is - what should be instead of

  return new LocalIterator();
3 Answers
Related