aspose file tools*
The moose likes Beginning Java and the fly likes collection Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "collection Interface" Watch "collection Interface" New topic
Author

collection Interface

Rajnarayan Deenadayalan
Greenhorn

Joined: Dec 16, 2003
Posts: 14
How Collection interfaces are implemented?
(i.e)Iterator is an iterface but we are able to use the methods of Iterator without implementing how it is possible .
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

The Java APIs provide many implementations. They're not generally public classes, so their names aren't visible. But calling, for example, ArrayList.iterator() will return an instance of a class, provided by the Java APIs, which implements the Iterator interface.


[Jess in Action][AskingGoodQuestions]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Rajnarayan Deenadayalan:
How Collection interfaces are implemented?
(i.e)Iterator is an iterface but we are able to use the methods of Iterator without implementing how it is possible .

Typically, the Collection interface is not implemented directly. The Collections Framework includes many subinterfaces that extend Collection, such as List, Map, and Set, which are in turn extended by yet other interfaces. These subinterfaces are typically the ones that you see implemented by classes such as ArrayList, TreeSet, and HashMap, to name a few.

The tutorials and documentation for the Collections Framework is quite extensive. You should probably start with

As Ernest pointed out, someone, somewhere DOES implement the Iterator interface. Typically the exact class that implements it is unknown.the Collections trailin Sun's Java Tutorial to get an idea of how the different Collection classes work. You should also familiarize yourself with the Java API documentation so you can look up what classes and methods are available for you to use.

I hope this answers your question. If not, please let us know.

Keep Coding!

Layne


Java API Documentation
The Java Tutorial
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: collection Interface