Hello, Jim.
In this lesson, I'll go to understand the main descendants of collection interface before going deep,
I believe it is very important to understand the big picture and learn three main interfaces in collections.
Iraqi today will hold a high level overview of such interfaces likely set.
And Q According to our agenda, we are going to start from the overview of the class diagram of collection
interface with its main descendants.
After that, I'm going to explain in simple words what a key difference is between three interfaces
and why we need them.
I will explain you what list is said and Q You use the explanation of the cube.
We are going to learn what f i f o principle is.
This lesson will help you to understand the first structure of our lessons and understand the core hierarchy
of collections.
Let's start here is our class diagram.
This one is the extended version of the one you saw in the previous lesson.
I believe you are already familiar with the collection interface.
Now let's look at the most popular child interfaces of collection interface that we are going to learn.
There are three interfaces that extends collection interface and that implemented by all the collection
implementations in GDP, Zaya least set and Q They're all collections.
But each interface is introduced in behavior on the quality of implementation of collection interface
by extending it.
Why do we need this interfaces?
Let me briefly go over each one.
Let's start from the least interface.
You already know that collection is just a back where you can put all your elements.
The list interface.
Introduce an ordered collection with the possibility to manage your elements by the index.
In the more simple words list is an order.
A collection of elements was all benefit.
That follows from that statement.
We can add element to the specific index and the collection.
We can get element by its index and we can replace existing element as a specific position to set the
new element in the specific position we have to use, said Mass.
With a specific index and element.
If we want, we can remove the element from the specific position in our list.
We can get the index of the first occurrence of the element in the specific collection and index of
the last occurrence of the specific element to perform these tasks.
Mass index of and last index should help us at least also allows us to get list iterator list iterator
that this extended version of the regular iterator in the separate class in about iterators.
And we'll explain the difference.
Sometimes we may want to create some lists, for example, to process back amount of data.
We may split our list into four equal chunks and perform any operations we need in four separate sets
of execution.
I believe you are aware that Java supports MultiThreaded and a bit later in the course, I'm also going
to teach you that.
Besides new absurd methods that were introduced, there are also to default matters that are absent
in connection interface and that are present in the list interface.
Zaya, replace all MassArt.
This method will take a function that can transform an element of one type to the element of the same
type.
We may want to use this method when we want, for example, transform all string objects in the list
to the string objects in the lowercase.
Sort method allows us to set the algorithm and to tell exactly how we want to certain elements in the
list, a bit later we're going to run such a functional interface as comparator.
Now, let's proceed with the collections Iraqi.
Let's talk about set interface.
What do you think?
What new methods are introduced in the set interface in comparison with collection interface?
No one is a set interface, doesn't introduce new methods.
Then why do we need it at all?
Let's recall what a set is from the mathematics.
The set is a well defined collection of discrete.
The set is a well defined collection of distinct objects.
The set interface is a main interface for the Iraqi of containers.
By the way, collections are often called containers.
So set is the main interface for the hierarchy of containers that contains only unique elements that
different implementations of the set interface during the development of JDK engineers come up with
the decisions that they need to distinguish a collection of elements and the set of elements.
Somehow the best decision was to introduce new interface.
So you're of development.
Engineers may declare variable of type set that would give us new methods to manipulate with elements
in the container.
But this instantly will give us the vision that this container contains only unique elements.
To understand how implementations of the set interface work, we need to learn map interfaces first.
We are going to understand later why.
And now let's review one more interface Hirschi interface.
There are a few new abstract methods were introduced here to manage the queue.
They are offer to insert an element into the queue, remove this method to retrieve and remove the head
of the queue.
But in case there is an empty queue, the method throws exception.
What is an exception?
And a bit later we are going to learn how Java programs may handle exceptional situations of program
execution.
Right now you can understand exception like something what is not an expected way of program execution
and what may potentially interrupt the program in case there is no code written that handles the exception
for this method also retrieves and removes the head of the queue the same as remove method, but with
only one difference in case queue is empty, there is no exception, no value is returned instead.
Element this MassArt retrieves but doesn't remove elements from the Q the same as remove method, it
throws exception in the case.
Q is empty.
Take Macit also retrieved but doesn't remove elements from the cube, with only one exception, that
in case there is an empty cube, no value is returned.
That's all new methods that were introduced in Q interface, no other default methods were introduced,
cues needed when you need to implement first in, first out principle, so-called f i f o principle,
imagine that you process support requests and you need to process them in the specific priority.
And according to the date, when you receive them the support you get that you received the earliest.
Exactly.
These tickets should be processed first.
And here you can understand what the queue is.
The first support that was received by Q The first left in the queue.
I feel really prepared.
Super interesting home task for you to improve our online store and to practice your skills in writing
use, but that will be later.
So right now I believe you understood the three main sub Iraqis that goes right after collection interface.
And also the structure of the next lesson should be clearer for you now during the next lesson.
So we are going to learn each interface in detail with all methods and to learn the most popular implementation
of each interface.
I want you to understand, Siiri, first before we start calling.
Believe me, this is very important.
But very soon you would beg me to stop quoting examples, I promise you.
Now, let's review what we have learned today.
Today we have learned what has remained descendants of collection interface.
Now you know why we need at least set new interfaces.
Moreover, after this lesson, you may understand the difference between them while explaining what
A is.
We learned f o principle.
Now you are ready for the next lesson.
Thanks a lot for your attention.
See you in the next lesson.