• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

collection Interface  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!