enfrptes

sendassignment@tutorspoint.com

The Iterator interface and ListIterator interface Homework Help

Tutorspoint.com is an excellent site, which caters to all queries of programming assignment help, regarding java assignments related to any topics of the Iterator interface and ListIterator interface homework help with quality solutions.

Since all the programming assignment writing help is offered at reasonable rates, Tutorspoint expert service is highly recommended by students worldwide from many universities of U.S. America, Australia, Canada, Germany, Ireland, and Denmark

 

What is The Iterator interface and ListIterator interface

1) Many times we may need to cycle through the elements in a collection. For example, we may want to display the catch element.

2) The easiest way to do this is to employ it in the iterator.

3) An iterator is an object that implements either the iterator or the list iterator interface.

4) Iterator enables us to cycle through a collection, obtaining or removing elements.

5) List iterator extends iterator to allow bidirectional traversal of a list and modification of the elements.

 

The methods declared by the Iterator interface are

Boolean has next ()

Returns true if there are more elements, otherwise, return false.

Object next ()

Returns the next element, throws no such element exception if there is not the next element.

void remove ()

Removes the current element, throws illegal state exception if an attempt is made to call remove () that is not preceded by a call to next ().

The methods declared by the List Iterator interface are:

Void Add (object obj)

Inserts object into the list in front of the elements that will be returned by the next call to next ()

Boolean has next ()

Returns true if there is a next element, otherwise, returns false

Boolean has previous ()

Returns true if there is a previous element, otherwise, return false

Object next ()

Returns the next element, a no such element exception is thrown if there is not the next element.

Int next index ()

Returns the index of the next element, if there is not the next element, returns the size of the list.

Object previous ()

Returns the previous element, no such element exception is thrown if there is not a previous element.

void remove ()

Removes the current element from the list, an illegal state exception is thrown if remove () is called before next () or previous () is invoked.

Void set ()

Assigns object to the current elements, this is the element last returned by a call to either next () or previous ().

The Iterator interface and ListIterator interface Homework Help