<< Chapter < Page Chapter >> Page >

Introduction

We learned in an earlier module that the framework provides at least nine concrete implementations of the interfaces in the framework. Thesenine implementation classes are available for immediate instantiation to produce objects to satisfy your collection needs.

We also learned that the framework provides at least three incomplete implementations. These classes are available for you to use as a starting point in defining yourown implementations. Default implementations of many of the interface methods are provided in the incomplete implementations.

Discussion and sample code

Purpose of implementations

The implementations in the Java Collections Framework are the concrete definitions of the classes that implement the core collection interfaces . For example, concrete implementations in the Java CollectionsFramework are provided by at least the following nine classes.

  • HashSet
  • TreeSet
  • LinkedList
  • ArrayList
  • Vector
  • HashMap
  • WeakHashMap
  • TreeMap
  • Hashtable

Available for immediate use

These classes are available for immediate use to instantiate collection objects.

As you can see, there are two classes that obviously fall into the Set category, two that obviously fall into the List category, and three that obviously fall into the Map category. You can learn more about the detailed characteristics of those classes in the standard Java documentation andin The Java Tutorials .

This leaves two additional classes whose names don't readily divulge the category to which they belong.

Vector and Hashtable classes

The classes Vector and Hashtable were part of Java even before the Java Collections Framework became available. The Vector class can be used to instantiate objects that fall in the general List category.

The Hashtable class can be used to instantiate objects that fall in the Map category.

These two classes have been upgraded to make them compatible with the Collections Framework.

Abstract implementations

In addition to the concrete implementations listed above, the following three classes partially implement the interfaces, but are not intended forinstantiation. Rather, they are intended to be extended into new concrete classes that you define.

  • AbstractSet
  • AbstractList
  • AbstractMap

Therefore, by either using one of the three classes listed above as a starting point, or by starting from scratch and fully implementing one or moreof the interfaces, you can provide new concrete implementations to augment the framework to include collections that meet your special needs. If you do that,be sure to satisfy the contract requirements of the Collections Framework in addition to the technical requirements imposed by implementing interfaces.

Purpose of algorithms

Algorithms are methods (not necessarily exposed) that provide useful capabilities, such as searching and sorting. For example, the Collection interface declares an exposed method named contains .

The contains method

The contract for the contains method requires that the method:

  • receives an incoming reference of type Object as a parameter
  • searches the collection looking for an element that matches the incoming reference
  • returns true if the collection on which the method is called contains the specified element and returns false otherwise.

Questions & Answers

what is mutation
Janga Reply
what is a cell
Sifune Reply
how is urine form
Sifune
what is antagonism?
mahase Reply
classification of plants, gymnosperm features.
Linsy Reply
what is the features of gymnosperm
Linsy
how many types of solid did we have
Samuel Reply
what is an ionic bond
Samuel
What is Atoms
Daprince Reply
what is fallopian tube
Merolyn
what is bladder
Merolyn
what's bulbourethral gland
Eduek Reply
urine is formed in the nephron of the renal medulla in the kidney. It starts from filtration, then selective reabsorption and finally secretion
onuoha Reply
State the evolution relation and relevance between endoplasmic reticulum and cytoskeleton as it relates to cell.
Jeremiah
what is heart
Konadu Reply
how is urine formed in human
Konadu
how is urine formed in human
Rahma
what is the diference between a cavity and a canal
Pelagie Reply
what is the causative agent of malaria
Diamond
malaria is caused by an insect called mosquito.
Naomi
Malaria is cause by female anopheles mosquito
Isaac
Malaria is caused by plasmodium Female anopheles mosquitoe is d carrier
Olalekan
a canal is more needed in a root but a cavity is a bad effect
Commander
what are pathogens
Don Reply
In biology, a pathogen (Greek: πάθος pathos "suffering", "passion" and -γενής -genēs "producer of") in the oldest and broadest sense, is anything that can produce disease. A pathogen may also be referred to as an infectious agent, or simply a germ. The term pathogen came into use in the 1880s.[1][2
Zainab
A virus
Commander
Definition of respiration
Muhsin Reply
respiration is the process in which we breath in oxygen and breath out carbon dioxide
Achor
how are lungs work
Commander
where does digestion begins
Achiri Reply
in the mouth
EZEKIEL
what are the functions of follicle stimulating harmones?
Rashima Reply
stimulates the follicle to release the mature ovum into the oviduct
Davonte
what are the functions of Endocrine and pituitary gland
Chinaza
endocrine secrete hormone and regulate body process
Achor
while pituitary gland is an example of endocrine system and it's found in the Brain
Achor
what's biology?
Egbodo Reply
Biology is the study of living organisms, divided into many specialized field that cover their morphology, physiology,anatomy, behaviour,origin and distribution.
Lisah
biology is the study of life.
Alfreda
Biology is the study of how living organisms live and survive in a specific environment
Sifune
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?

Ask