• Post Reply Bookmark Topic Watch Topic
  • New Topic

where is the source code of iterator.next() implemented.  RSS feed

 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iterator is an interface then where is the implementations of iterator methods.
collection is also a interface then where is the implementation.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is not just one implementation of Iterator. Each collection class has its own implementation, and how it works exactly depends on the collection class that the iterator is for. If you want to see what for example the Iterator of class ArrayList looks like, then look for the source code of ArrayList in the file src.zip in your JDK installation directory. Lookup the source code of the iterator() method in class ArrayList. Other collections, such as LinkedList, will have another implementation of Iterator.

The same with Collection - there are a number of classes that implement the Collection interface.

Have a look at the API documentation of for example java.util.Collection. Note that at the top there is a list "All Known Implementing Classes". Those are the classes in the standard library that implement the interface.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!