Here is my code:
import java.util.List; public class ItemList implements Iterable<Entry> { private List<Entry> entries; public static class Entry { private final String id; private int quantity; } @Overide public Iterator<Entry> iterator() { return entries.iterator(); } }
This code will not compile. (He claims that he cannot find the type "Entry" in the definition of the ItemList class).
I want other classes to be able to iterate over the internal entries of this list. I would prefer not to transfer the Entry class to a separate file, as this would require exposing many of the inner workings of this class to all other classes in the package.
My question is: why is this not compiling? And what is the best way to solve this problem?
source share