I\'ve created a linked list in java using generics, and now I want to be able to iterate over all the elements in the list. In C# I would use yield return insid
Am I missing something here? There is already java.util.LinkedList, it is fully generics-enabled, and it has a method which returns an Iterator.
If you really want to re-invent the wheel, I'd suggest you look into to creating a LinkedListIterator class, probably implementing ListIterator. It would remember its current position within the linked list and advance it on each successive call.