java-development-for-beginners-learnit / 19 - Java Collections Framework /001 Java Collections Framework Overview_en.srt
| 1 | |
| 00:00:06,000 --> 00:00:06,000 | |
| Hello. | |
| 2 | |
| 00:00:06,000 --> 00:00:10,000 | |
| Students in this region, I'm going to make overview of Java collections framework. | |
| 3 | |
| 00:00:10,000 --> 00:00:15,000 | |
| I want you to understand general structure of Java collections framework before we start going deeper | |
| 4 | |
| 00:00:15,000 --> 00:00:16,000 | |
| in the details. | |
| 5 | |
| 00:00:16,000 --> 00:00:18,000 | |
| And here's our agenda for the day. | |
| 6 | |
| 00:00:18,000 --> 00:00:21,000 | |
| We'll talk about what GSF includes in this lesson. | |
| 7 | |
| 00:00:21,000 --> 00:00:24,000 | |
| You are going to learn the difference between collections and the rates. | |
| 8 | |
| 00:00:24,000 --> 00:00:28,000 | |
| We are going to discuss what advantages collections have over their rates. | |
| 9 | |
| 00:00:28,000 --> 00:00:34,000 | |
| Also, during the lesson, we are going to talk about two separate Iraqis in Java collections framework | |
| 10 | |
| 00:00:34,000 --> 00:00:37,000 | |
| that Zeta's Iraqi of collections and hierarchy of maps. | |
| 11 | |
| 00:00:37,000 --> 00:00:39,000 | |
| And what are the difference between them? | |
| 12 | |
| 00:00:39,000 --> 00:00:44,000 | |
| I believe this is going to help you significantly to understand the core structure and the next lessons | |
| 13 | |
| 00:00:44,000 --> 00:00:45,000 | |
| in general. | |
| 14 | |
| 00:00:45,000 --> 00:00:50,000 | |
| So let's start and to start with let's answer the question. | |
| 15 | |
| 00:00:50,000 --> 00:00:54,000 | |
| What does you see, if I will shut and Java collections framework, if you don't mind. | |
| 16 | |
| 00:00:54,000 --> 00:00:56,000 | |
| What does it consist of? | |
| 17 | |
| 00:00:56,000 --> 00:01:02,000 | |
| GCF is a unified name for the group of the types and algorithms that are developed to store elements | |
| 18 | |
| 00:01:02,000 --> 00:01:05,000 | |
| in them and perform manipulations on the group of the objects. | |
| 19 | |
| 00:01:06,000 --> 00:01:10,000 | |
| GCF includes next things, collection interfaces. | |
| 20 | |
| 00:01:10,000 --> 00:01:16,000 | |
| These are abstract data types that describes the type that my group, multiple elements in the single | |
| 21 | |
| 00:01:16,000 --> 00:01:21,000 | |
| unit as a software engineer, are going to use collections all the times to perform operations with | |
| 22 | |
| 00:01:21,000 --> 00:01:26,000 | |
| the group of objects, for example, product list in our Web application. | |
| 23 | |
| 00:01:26,000 --> 00:01:32,000 | |
| This might be a collection of products in the language of Java, and we could perform operations on | |
| 24 | |
| 00:01:32,000 --> 00:01:37,000 | |
| the group of the products, for example, search products, or filter them to keep only products that | |
| 25 | |
| 00:01:37,000 --> 00:01:43,000 | |
| has priced more than ten dollars or split all the group of products on the equal chance to show products | |
| 26 | |
| 00:01:43,000 --> 00:01:45,000 | |
| page by page and a lot of other things. | |
| 27 | |
| 00:01:46,000 --> 00:01:49,000 | |
| Can you understand now why we might need collections? | |
| 28 | |
| 00:01:50,000 --> 00:01:51,000 | |
| You might think. | |
| 29 | |
| 00:01:51,000 --> 00:01:56,000 | |
| Isn't that the same what we have arrays for take into account you used to raise already? | |
| 30 | |
| 00:01:56,000 --> 00:02:02,000 | |
| You might think that for the same purposes you would use arrays a bit later when we would talk about | |
| 31 | |
| 00:02:02,000 --> 00:02:04,000 | |
| advantages of collections of arrays. | |
| 32 | |
| 00:02:04,000 --> 00:02:10,000 | |
| You would understand why arrays and collections are two different things implementations of collection | |
| 33 | |
| 00:02:10,000 --> 00:02:16,000 | |
| interfaces, even despite the fact that abstractions for collections looks the same, the implementation | |
| 34 | |
| 00:02:16,000 --> 00:02:20,000 | |
| of this interface at different and fits for different goals. | |
| 35 | |
| 00:02:20,000 --> 00:02:26,000 | |
| For example, some collections work the best for adding new elements since the end of the collection, | |
| 36 | |
| 00:02:26,000 --> 00:02:31,000 | |
| and developers like that collections because of the constant time of retrieving element from them. | |
| 37 | |
| 00:02:31,000 --> 00:02:36,000 | |
| Are the collections work better when you need to add elements in the middle or at the beginning of the | |
| 38 | |
| 00:02:36,000 --> 00:02:37,000 | |
| collection? | |
| 39 | |
| 00:02:38,000 --> 00:02:41,000 | |
| Other collections work the best in the current environment. | |
| 40 | |
| 00:02:41,000 --> 00:02:46,000 | |
| We are going to learn all of these collections and to understand the difference when to use each collection | |
| 41 | |
| 00:02:46,000 --> 00:02:47,000 | |
| type. | |
| 42 | |
| 00:02:48,000 --> 00:02:55,000 | |
| Map interfaces, map interface at different from collections in one important think map is a container | |
| 43 | |
| 00:02:55,000 --> 00:02:58,000 | |
| that contains pairs of key and value. | |
| 44 | |
| 00:02:59,000 --> 00:03:05,000 | |
| For example, you may the name of the product category, for example, doors and collections of all | |
| 45 | |
| 00:03:05,000 --> 00:03:07,000 | |
| doors associated with it. | |
| 46 | |
| 00:03:07,000 --> 00:03:12,000 | |
| You might have goods category and collection of booths associated with that key. | |
| 47 | |
| 00:03:13,000 --> 00:03:19,000 | |
| And in case you need to get all doors, you just make a request to the map button on the key to it to | |
| 48 | |
| 00:03:19,000 --> 00:03:21,000 | |
| retrieve all doors. | |
| 49 | |
| 00:03:21,000 --> 00:03:22,000 | |
| Does it make sense? | |
| 50 | |
| 00:03:23,000 --> 00:03:29,000 | |
| Maps are also considered a part of the collections framework because even if they don't have the same | |
| 51 | |
| 00:03:29,000 --> 00:03:35,000 | |
| interface as collections, they have operations that allow us to view and interact with them the same | |
| 52 | |
| 00:03:35,000 --> 00:03:36,000 | |
| way as with collections. | |
| 53 | |
| 00:03:37,000 --> 00:03:43,000 | |
| Implementation of MAP interfaces unions, of course, we are going to discuss different implementations | |
| 54 | |
| 00:03:43,000 --> 00:03:48,000 | |
| of the map and we are going to understand when we will use each implementation of the map interface. | |
| 55 | |
| 00:03:49,000 --> 00:03:55,000 | |
| Deprecated collections, deprecated collections are also part of the Java collections framework, despite | |
| 56 | |
| 00:03:55,000 --> 00:04:00,000 | |
| the fact that it is recommended not to use specific collections sometimes on the Java project. | |
| 57 | |
| 00:04:00,000 --> 00:04:02,000 | |
| You still going to work with them? | |
| 58 | |
| 00:04:03,000 --> 00:04:09,000 | |
| Because even nowadays there are a lot of old projects written on Java that require support and maintenance, | |
| 59 | |
| 00:04:10,000 --> 00:04:11,000 | |
| synchronized collections. | |
| 60 | |
| 00:04:12,000 --> 00:04:17,000 | |
| There are also special set of collections that are developed to be used in the multithreaded environment. | |
| 61 | |
| 00:04:17,000 --> 00:04:19,000 | |
| Let me tell you the example to make you understand. | |
| 62 | |
| 00:04:20,000 --> 00:04:25,000 | |
| Imagine that you have collections of users and one administrator of the website removes the user from | |
| 63 | |
| 00:04:25,000 --> 00:04:31,000 | |
| the collection and another administrator of the website is iterating over each user in the same collection | |
| 64 | |
| 00:04:31,000 --> 00:04:33,000 | |
| to update the state of the total. | |
| 65 | |
| 00:04:33,000 --> 00:04:39,000 | |
| Orders about the conflict might appear when two administrators in the two separate threats of execution | |
| 66 | |
| 00:04:40,000 --> 00:04:41,000 | |
| would obtain the same collection. | |
| 67 | |
| 00:04:42,000 --> 00:04:47,000 | |
| In this course, I'm going to tell you how centralized collections work and how to use them. | |
| 68 | |
| 00:04:48,000 --> 00:04:50,000 | |
| Algorithms also. | |
| 69 | |
| 00:04:50,000 --> 00:04:56,000 | |
| GCF includes algorithms that are the methods that perform useful computations, such as searching and | |
| 70 | |
| 00:04:56,000 --> 00:05:03,000 | |
| sorting on objects that implement collection interfaces that algorithms are said to be polymorphic. | |
| 71 | |
| 00:05:03,000 --> 00:05:08,000 | |
| That is, the same method can be used on many different implementations of the appropriate collection | |
| 72 | |
| 00:05:08,000 --> 00:05:09,000 | |
| interface. | |
| 73 | |
| 00:05:10,000 --> 00:05:17,000 | |
| Robbers GCF contains a special wrapper that can turn your regular collection into non modifiable collection | |
| 74 | |
| 00:05:18,000 --> 00:05:23,000 | |
| or wrapper, that can turn your regular collection into synchronized collection that you can use and | |
| 75 | |
| 00:05:23,000 --> 00:05:24,000 | |
| will just write an environment. | |
| 76 | |
| 00:05:25,000 --> 00:05:31,000 | |
| Now, when you know what a collection framework consists of, let's discuss what advantages does it | |
| 77 | |
| 00:05:31,000 --> 00:05:32,000 | |
| have over race? | |
| 78 | |
| 00:05:33,000 --> 00:05:36,000 | |
| Let's go over this table to compare collections and race. | |
| 79 | |
| 00:05:37,000 --> 00:05:41,000 | |
| This table will help you to understand what advantage collections have over race. | |
| 80 | |
| 00:05:42,000 --> 00:05:48,000 | |
| First of all, you already know that our racing driver have fixed size collections in Java can be extended | |
| 81 | |
| 00:05:48,000 --> 00:05:49,000 | |
| dynamically. | |
| 82 | |
| 00:05:49,000 --> 00:05:54,000 | |
| So using collections, there is no need to create new collection and copy the state of the previous | |
| 83 | |
| 00:05:54,000 --> 00:05:59,000 | |
| collection into the new one when you run out of space in this old collection. | |
| 84 | |
| 00:05:59,000 --> 00:06:02,000 | |
| There's a significant benefit for the development process. | |
| 85 | |
| 00:06:03,000 --> 00:06:10,000 | |
| Secondly, our race itself does not have any behavior and algorithms to work with them, for example, | |
| 86 | |
| 00:06:10,000 --> 00:06:18,000 | |
| a race can't filter themselves or find the first index of appearance of element or keep all elements | |
| 87 | |
| 00:06:18,000 --> 00:06:25,000 | |
| sorted automatically or have only unique elements and do not add elements that already exist in collection | |
| 88 | |
| 00:06:25,000 --> 00:06:26,000 | |
| and a lot of other things. | |
| 89 | |
| 00:06:27,000 --> 00:06:33,000 | |
| If you remember a race class, you may say that some of the algorithms are present in a race class to | |
| 90 | |
| 00:06:33,000 --> 00:06:34,000 | |
| work with the race. | |
| 91 | |
| 00:06:34,000 --> 00:06:40,000 | |
| But the amount of operations that you can do with our race class is significantly lower than a number | |
| 92 | |
| 00:06:40,000 --> 00:06:43,000 | |
| of algorithms that Java collections framework has. | |
| 93 | |
| 00:06:43,000 --> 00:06:50,000 | |
| And moreover, we mentioned separate class and static methods in a race class that is not the same as | |
| 94 | |
| 00:06:50,000 --> 00:06:53,000 | |
| behavior of the object like we have in collections. | |
| 95 | |
| 00:06:54,000 --> 00:07:00,000 | |
| Certainly collections have single API and no matter what is the specifics of each particular implementation | |
| 96 | |
| 00:07:00,000 --> 00:07:06,000 | |
| of the collection, whether it's stauss only unique elements or supports region of elements during the | |
| 97 | |
| 00:07:06,000 --> 00:07:08,000 | |
| constant amount of time, it doesn't matter. | |
| 98 | |
| 00:07:09,000 --> 00:07:11,000 | |
| All collections have common API. | |
| 99 | |
| 00:07:11,000 --> 00:07:15,000 | |
| What significantly simplifies usage of collections and running them. | |
| 100 | |
| 00:07:16,000 --> 00:07:21,000 | |
| On the other hand, working with arrays e.g. developer may implement his own application programming | |
| 101 | |
| 00:07:21,000 --> 00:07:23,000 | |
| interface to interact with a rate. | |
| 102 | |
| 00:07:23,000 --> 00:07:29,000 | |
| For example, the developer may come up with a method to add a new element in array and extend it in | |
| 103 | |
| 00:07:29,000 --> 00:07:31,000 | |
| case there is no more Plaisance. | |
| 104 | |
| 00:07:31,000 --> 00:07:35,000 | |
| Every developer may come up with a specific algorithm. | |
| 105 | |
| 00:07:35,000 --> 00:07:37,000 | |
| How to clear all elements in array. | |
| 106 | |
| 00:07:37,000 --> 00:07:42,000 | |
| One developer will just create a new array with the default array size and as a developer would just | |
| 107 | |
| 00:07:42,000 --> 00:07:48,000 | |
| turn into new values or current elements in array and the already might use a problem and such approach. | |
| 108 | |
| 00:07:48,000 --> 00:07:52,000 | |
| There is no single API when you are working with arrays. | |
| 109 | |
| 00:07:53,000 --> 00:07:58,000 | |
| By having such data structures and algorithms as collections, developers may concentrate on the important | |
| 110 | |
| 00:07:58,000 --> 00:08:03,000 | |
| parts of the program rather than on the low level work and inventions of your. | |
| 111 | |
| 00:08:04,000 --> 00:08:10,000 | |
| Forcedly, what you need to remember, collections can store only reference types of data collections | |
| 112 | |
| 00:08:10,000 --> 00:08:12,000 | |
| doesn't work with primitive types of data. | |
| 113 | |
| 00:08:13,000 --> 00:08:17,000 | |
| If you want to store primitive types of data because of the performance reasons, you still have to | |
| 114 | |
| 00:08:17,000 --> 00:08:18,000 | |
| use arrays. | |
| 115 | |
| 00:08:19,000 --> 00:08:21,000 | |
| And last but not the least performance. | |
| 116 | |
| 00:08:22,000 --> 00:08:26,000 | |
| Usually it is considered the performance of arrays is higher than performance of collections. | |
| 117 | |
| 00:08:27,000 --> 00:08:32,000 | |
| While this can be true in the modern world, in the most of business cases we are talking about milliseconds | |
| 118 | |
| 00:08:32,000 --> 00:08:38,000 | |
| difference for standard operations and for standard number of elements in either collection or array. | |
| 119 | |
| 00:08:38,000 --> 00:08:44,000 | |
| But you have to know about this and now you have the vision of what we are going to learn and what Java | |
| 120 | |
| 00:08:44,000 --> 00:08:45,000 | |
| collections framework is. | |
| 121 | |
| 00:08:46,000 --> 00:08:49,000 | |
| As you can see, there are really a lot of things to learn. | |
| 122 | |
| 00:08:50,000 --> 00:08:52,000 | |
| Right now, let's recap what we have learned today. | |
| 123 | |
| 00:08:53,000 --> 00:08:57,000 | |
| In this lesson, we learned what Java collections framework contains on the high level. | |
| 124 | |
| 00:08:57,000 --> 00:09:03,000 | |
| We understand what collections are and how they are different from maps during the last very of the | |
| 125 | |
| 00:09:03,000 --> 00:09:09,000 | |
| main advantages of collections of arrays and also discussed what advantages arrays have over collections. | |
| 126 | |
| 00:09:10,000 --> 00:09:11,000 | |
| That's all for now. | |
| 127 | |
| 00:09:12,000 --> 00:09:15,000 | |
| Thanks a lot for your attention and to you in the next lesson. | |