What differences exist between Iterator and ListIterator ?
What differences exist between Iterator and ListIterator ?
The differences between the Iterator and ListIterator interfaces in Java primarily revolve around their capabilities and the types of collections they can traverse. Here are the key distinctions:
Set
, List
, and Map
[1][2][3][4][5][6].List
type collections only, such as ArrayList
and LinkedList
. It cannot be used with Set
or Map
[1][2][3][4][5][6].hasNext()
, next()
, and remove()
[1][2][3][4][5][6].hasPrevious()
, previous()
, nextIndex()
, previousIndex()
, set()
, and add()
. These methods allow not only moving back and forth but also modifying the list during iteration and obtaining indexes of elements during traversal[1][2][3][4][5][6].ConcurrentModificationException
[2][3][...middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào