<< Chapter < Page Chapter >> Page >

While you will ultimately need to understand how to use Generics, that is a very complex topic. An understanding of Generics is beyond the scope of thiscourse. Therefore, for purposes of this course, you can simply ignore those warnings.

Discussion

We will start with a quiz

I am going to begin this module with a quiz just to make sure that you are still awake. Is the following statement Trueor False?

The TreeSet class is a direct implementation of the Collection interface.

The answer is False.

The TreeSet class is not a direct implementation of the Collection interface. Rather, the TreeSet class is a direct implementation of the SortedSet interface. The SortedSet interface extends the Set interface, and the Set interface extends the Collection interface.

The interface hierarchy for the Java Collections Framework is shown below:

  • Collection
    • Set
      • SortedSet
    • List
    • Queue
    • Deque
  • Map
    • SortedMap

As you learned in an earlier module, the Java Collections Framework doesn't have a single root. As shown above, there are two distinct trees in theframework -- The Collection hierarchy and the Map hierarchy.

The root of the Collection hierarchy

The Collection interface is the root of the collection hierarchy. The Java Collections Framework doesn't provide any direct implementations of the Collection interface. All of the implementations of the interfaces in the Collection hierarchy implement one of the sub-interfaces of the Collection interface.

What does Oracle say about this?

Here is what the Oracle documentation has to say on the topic of the Collection interface:

"The SDK does not provide any direct implementations of this interface: it provides implementations of more specific sub-interfaces like Set and List . This interface is typically used to pass collections around and manipulate them wheremaximum generality is desired."

The Oracle documentation also states:

"Bags or multisets (unordered collections that may contain duplicate elements) should implement this interface directly."

What about duplicate elements?

Some implementations of Collection allow duplicate elements, and others do not. Implementations of the List interface (such as ArrayList ) allow duplicate elements. Implements of Set and SortedSet (such as TreeSet ) do not allow duplicate elements. This was illustrated in an earlier module.

A sample program in that earlier module created two collection objects and applied the polymorphic add method to add the same elements to each collection. One of the collection objects was of type ArrayList , and the other collection object was of type TreeSet . The elements added to each collection contained one pair of duplicate elements. The duplicate elementwas automatically excluded from the TreeSet object, but was retained in the ArrayList object.

What is a set?

According to Oracle, a Set is a "collection that contains no duplicate elements ... this interface models the mathematical set abstraction."

An object of type Set is typically used to model collections such as Social Security numbers, where duplicates are not allowed.

What is a list?

Also according to Oracle, a List is "An ordered collection (also known as a sequence). The user of this interface has precise control over where in thelist each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list."

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
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