Iterator is a collection iterator that does not have to care for the implementation of the collection through the Iterator Access interface. ITERATOR interface defines three methods: 1.HASNext () Whether there is the next element .2.next () Returns the next element .3.Remove () Deletes the current element.
Simple three methods are defined, you have to pay attention to a few points: 1) Iterator and Enumeration The differences of Iterator is used to replace ENUMERATION, and two methods are defined in Enumeration, which does not have delete function. 2) call next () After the method, the remove () method can only be called, and the REMOVE () method can only be called each time the next () is called, otherwise ILLEGALSTATEEXCEPTION exception can be thrown.