Tell me what is the difference between an Iterator and a ListIterator?
Submitted by: MuhammadThis question tests the proper usage of collection iterators. One can only use ListIterator to traverse Lists, and cannot traverse a Set using ListIterator.
What's more, one can only traverse in a forward direction using Iterators. Using ListIterator, one can traverse a List in both the directions (forward and backward).
One cannot obtain indexes while using Iterator. Indexes can be obtained at any point of time while traversing a list using ListIterator. The methods nextIndex() and previousIndex() are used for this purpose.
Submitted by: Muhammad
What's more, one can only traverse in a forward direction using Iterators. Using ListIterator, one can traverse a List in both the directions (forward and backward).
One cannot obtain indexes while using Iterator. Indexes can be obtained at any point of time while traversing a list using ListIterator. The methods nextIndex() and previousIndex() are used for this purpose.
Submitted by: Muhammad
Read Online Java Software Engineer Job Interview Questions And Answers
Top Java Software Engineer Questions
☺ | Do you know how threadsafe is enum in Java? |
☺ | Explain me what is a good usecase of calling System.gc()? |
☺ | Explain me why doesn’t the following code generate a NullPointerException even when the instance is null? |
☺ | Do you know what is the advantage of generic collection? |
☺ | Tell us what do you mean by aggregation? |
Top Java Programming Language Categories
☺ | Core Java Interview Questions. |
☺ | Hibernate Interview Questions. |
☺ | Advanced Java Interview Questions. |
☺ | IBM WebSphere Interview Questions. |
☺ | Spring Framework Interview Questions. |