In this program we will make direct use of an iterator (an enumerator) instead of traversing with use of foreach. In the animal collection program, which we have seen earlier in this lecture, we traverse the animal collections several times with use of foreach. Replace each use of foreach with an application of an iterator. |