Hello.
Students in this region, I'm going to make overview of Java collections framework.
I want you to understand general structure of Java collections framework before we start going deeper
in the details.
And here's our agenda for the day.
We'll talk about what GSF includes in this lesson.
You are going to learn the difference between collections and the rates.
We are going to discuss what advantages collections have over their rates.
Also, during the lesson, we are going to talk about two separate Iraqis in Java collections framework
that Zeta's Iraqi of collections and hierarchy of maps.
And what are the difference between them?
I believe this is going to help you significantly to understand the core structure and the next lessons
in general.
So let's start and to start with let's answer the question.
What does you see, if I will shut and Java collections framework, if you don't mind.
What does it consist of?
GCF is a unified name for the group of the types and algorithms that are developed to store elements
in them and perform manipulations on the group of the objects.
GCF includes next things, collection interfaces.
These are abstract data types that describes the type that my group, multiple elements in the single
unit as a software engineer, are going to use collections all the times to perform operations with
the group of objects, for example, product list in our Web application.
This might be a collection of products in the language of Java, and we could perform operations on
the group of the products, for example, search products, or filter them to keep only products that
has priced more than ten dollars or split all the group of products on the equal chance to show products
page by page and a lot of other things.
Can you understand now why we might need collections?
You might think.
Isn't that the same what we have arrays for take into account you used to raise already?
You might think that for the same purposes you would use arrays a bit later when we would talk about
advantages of collections of arrays.
You would understand why arrays and collections are two different things implementations of collection
interfaces, even despite the fact that abstractions for collections looks the same, the implementation
of this interface at different and fits for different goals.
For example, some collections work the best for adding new elements since the end of the collection,
and developers like that collections because of the constant time of retrieving element from them.
Are the collections work better when you need to add elements in the middle or at the beginning of the
collection?
Other collections work the best in the current environment.
We are going to learn all of these collections and to understand the difference when to use each collection
type.
Map interfaces, map interface at different from collections in one important think map is a container
that contains pairs of key and value.
For example, you may the name of the product category, for example, doors and collections of all
doors associated with it.
You might have goods category and collection of booths associated with that key.
And in case you need to get all doors, you just make a request to the map button on the key to it to
retrieve all doors.
Does it make sense?
Maps are also considered a part of the collections framework because even if they don't have the same
interface as collections, they have operations that allow us to view and interact with them the same
way as with collections.
Implementation of MAP interfaces unions, of course, we are going to discuss different implementations
of the map and we are going to understand when we will use each implementation of the map interface.
Deprecated collections, deprecated collections are also part of the Java collections framework, despite
the fact that it is recommended not to use specific collections sometimes on the Java project.
You still going to work with them?
Because even nowadays there are a lot of old projects written on Java that require support and maintenance,
synchronized collections.
There are also special set of collections that are developed to be used in the multithreaded environment.
Let me tell you the example to make you understand.
Imagine that you have collections of users and one administrator of the website removes the user from
the collection and another administrator of the website is iterating over each user in the same collection
to update the state of the total.
Orders about the conflict might appear when two administrators in the two separate threats of execution
would obtain the same collection.
In this course, I'm going to tell you how centralized collections work and how to use them.
Algorithms also.
GCF includes algorithms that are the methods that perform useful computations, such as searching and
sorting on objects that implement collection interfaces that algorithms are said to be polymorphic.
That is, the same method can be used on many different implementations of the appropriate collection
interface.
Robbers GCF contains a special wrapper that can turn your regular collection into non modifiable collection
or wrapper, that can turn your regular collection into synchronized collection that you can use and
will just write an environment.
Now, when you know what a collection framework consists of, let's discuss what advantages does it
have over race?
Let's go over this table to compare collections and race.
This table will help you to understand what advantage collections have over race.
First of all, you already know that our racing driver have fixed size collections in Java can be extended
dynamically.
So using collections, there is no need to create new collection and copy the state of the previous
collection into the new one when you run out of space in this old collection.
There's a significant benefit for the development process.
Secondly, our race itself does not have any behavior and algorithms to work with them, for example,
a race can't filter themselves or find the first index of appearance of element or keep all elements
sorted automatically or have only unique elements and do not add elements that already exist in collection
and a lot of other things.
If you remember a race class, you may say that some of the algorithms are present in a race class to
work with the race.
But the amount of operations that you can do with our race class is significantly lower than a number
of algorithms that Java collections framework has.
And moreover, we mentioned separate class and static methods in a race class that is not the same as
behavior of the object like we have in collections.
Certainly collections have single API and no matter what is the specifics of each particular implementation
of the collection, whether it's stauss only unique elements or supports region of elements during the
constant amount of time, it doesn't matter.
All collections have common API.
What significantly simplifies usage of collections and running them.
On the other hand, working with arrays e.g. developer may implement his own application programming
interface to interact with a rate.
For example, the developer may come up with a method to add a new element in array and extend it in
case there is no more Plaisance.
Every developer may come up with a specific algorithm.
How to clear all elements in array.
One developer will just create a new array with the default array size and as a developer would just
turn into new values or current elements in array and the already might use a problem and such approach.
There is no single API when you are working with arrays.
By having such data structures and algorithms as collections, developers may concentrate on the important
parts of the program rather than on the low level work and inventions of your.
Forcedly, what you need to remember, collections can store only reference types of data collections
doesn't work with primitive types of data.
If you want to store primitive types of data because of the performance reasons, you still have to
use arrays.
And last but not the least performance.
Usually it is considered the performance of arrays is higher than performance of collections.
While this can be true in the modern world, in the most of business cases we are talking about milliseconds
difference for standard operations and for standard number of elements in either collection or array.
But you have to know about this and now you have the vision of what we are going to learn and what Java
collections framework is.
As you can see, there are really a lot of things to learn.
Right now, let's recap what we have learned today.
In this lesson, we learned what Java collections framework contains on the high level.
We understand what collections are and how they are different from maps during the last very of the
main advantages of collections of arrays and also discussed what advantages arrays have over collections.
That's all for now.
Thanks a lot for your attention and to you in the next lesson.