java - What class is directly implementing ListIterator? -


what class implements interface listiterator? i'm studying collections api.. , seem though actual method returns listiterator within list implementation classes directly specified in list itself.

the listiterator interface specifies actual methods use manipulate iterator.. having trouble finding actual class implements this.

what class -implements- interface listiterator allows method in list classes work?

i'm sure there has implementation class because calling listiterator() surely can not return interface, there must instantiated.

you can't instantiate interface, can create "invisible" private class, satisfying interface, user can't directly see it. example, linkedlist defines listiterator as:

public listiterator<e> listiterator(int index) {     checkpositionindex(index);     return new listitr(index); }  private class listitr implements listiterator<e> {     private node<e> lastreturned;     private node<e> next;     private int nextindex;     private int expectedmodcount = modcount;      listitr(int index) {         // assert ispositionindex(index);         next = (index == size) ? null : node(index);         nextindex = index;     }      // more } 

this behavior have it's final form in lambdas, in won't have temptation looking in sources of passed class.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -