1 00:00:06,000 --> 00:00:06,000 Hello, Jim. 2 00:00:06,000 --> 00:00:12,000 In this lesson, I'll go to understand the main descendants of collection interface before going deep, 3 00:00:12,000 --> 00:00:18,000 I believe it is very important to understand the big picture and learn three main interfaces in collections. 4 00:00:18,000 --> 00:00:23,000 Iraqi today will hold a high level overview of such interfaces likely set. 5 00:00:23,000 --> 00:00:29,000 And Q According to our agenda, we are going to start from the overview of the class diagram of collection 6 00:00:29,000 --> 00:00:32,000 interface with its main descendants. 7 00:00:32,000 --> 00:00:37,000 After that, I'm going to explain in simple words what a key difference is between three interfaces 8 00:00:37,000 --> 00:00:38,000 and why we need them. 9 00:00:39,000 --> 00:00:44,000 I will explain you what list is said and Q You use the explanation of the cube. 10 00:00:44,000 --> 00:00:48,000 We are going to learn what f i f o principle is. 11 00:00:48,000 --> 00:00:54,000 This lesson will help you to understand the first structure of our lessons and understand the core hierarchy 12 00:00:54,000 --> 00:00:55,000 of collections. 13 00:00:55,000 --> 00:00:58,000 Let's start here is our class diagram. 14 00:00:59,000 --> 00:01:02,000 This one is the extended version of the one you saw in the previous lesson. 15 00:01:03,000 --> 00:01:06,000 I believe you are already familiar with the collection interface. 16 00:01:06,000 --> 00:01:12,000 Now let's look at the most popular child interfaces of collection interface that we are going to learn. 17 00:01:12,000 --> 00:01:18,000 There are three interfaces that extends collection interface and that implemented by all the collection 18 00:01:18,000 --> 00:01:25,000 implementations in GDP, Zaya least set and Q They're all collections. 19 00:01:25,000 --> 00:01:32,000 But each interface is introduced in behavior on the quality of implementation of collection interface 20 00:01:32,000 --> 00:01:33,000 by extending it. 21 00:01:33,000 --> 00:01:35,000 Why do we need this interfaces? 22 00:01:36,000 --> 00:01:38,000 Let me briefly go over each one. 23 00:01:39,000 --> 00:01:40,000 Let's start from the least interface. 24 00:01:41,000 --> 00:01:45,000 You already know that collection is just a back where you can put all your elements. 25 00:01:46,000 --> 00:01:47,000 The list interface. 26 00:01:47,000 --> 00:01:52,000 Introduce an ordered collection with the possibility to manage your elements by the index. 27 00:01:53,000 --> 00:01:56,000 In the more simple words list is an order. 28 00:01:56,000 --> 00:01:58,000 A collection of elements was all benefit. 29 00:01:58,000 --> 00:02:00,000 That follows from that statement. 30 00:02:01,000 --> 00:02:04,000 We can add element to the specific index and the collection. 31 00:02:04,000 --> 00:02:11,000 We can get element by its index and we can replace existing element as a specific position to set the 32 00:02:11,000 --> 00:02:14,000 new element in the specific position we have to use, said Mass. 33 00:02:15,000 --> 00:02:17,000 With a specific index and element. 34 00:02:18,000 --> 00:02:22,000 If we want, we can remove the element from the specific position in our list. 35 00:02:22,000 --> 00:02:28,000 We can get the index of the first occurrence of the element in the specific collection and index of 36 00:02:28,000 --> 00:02:32,000 the last occurrence of the specific element to perform these tasks. 37 00:02:32,000 --> 00:02:41,000 Mass index of and last index should help us at least also allows us to get list iterator list iterator 38 00:02:41,000 --> 00:02:46,000 that this extended version of the regular iterator in the separate class in about iterators. 39 00:02:46,000 --> 00:02:47,000 And we'll explain the difference. 40 00:02:48,000 --> 00:02:54,000 Sometimes we may want to create some lists, for example, to process back amount of data. 41 00:02:54,000 --> 00:03:00,000 We may split our list into four equal chunks and perform any operations we need in four separate sets 42 00:03:00,000 --> 00:03:01,000 of execution. 43 00:03:02,000 --> 00:03:07,000 I believe you are aware that Java supports MultiThreaded and a bit later in the course, I'm also going 44 00:03:07,000 --> 00:03:08,000 to teach you that. 45 00:03:09,000 --> 00:03:14,000 Besides new absurd methods that were introduced, there are also to default matters that are absent 46 00:03:14,000 --> 00:03:17,000 in connection interface and that are present in the list interface. 47 00:03:18,000 --> 00:03:20,000 Zaya, replace all MassArt. 48 00:03:20,000 --> 00:03:26,000 This method will take a function that can transform an element of one type to the element of the same 49 00:03:26,000 --> 00:03:26,000 type. 50 00:03:27,000 --> 00:03:32,000 We may want to use this method when we want, for example, transform all string objects in the list 51 00:03:32,000 --> 00:03:35,000 to the string objects in the lowercase. 52 00:03:36,000 --> 00:03:42,000 Sort method allows us to set the algorithm and to tell exactly how we want to certain elements in the 53 00:03:42,000 --> 00:03:47,000 list, a bit later we're going to run such a functional interface as comparator. 54 00:03:48,000 --> 00:03:50,000 Now, let's proceed with the collections Iraqi. 55 00:03:50,000 --> 00:03:52,000 Let's talk about set interface. 56 00:03:53,000 --> 00:03:54,000 What do you think? 57 00:03:54,000 --> 00:03:59,000 What new methods are introduced in the set interface in comparison with collection interface? 58 00:04:00,000 --> 00:04:04,000 No one is a set interface, doesn't introduce new methods. 59 00:04:05,000 --> 00:04:06,000 Then why do we need it at all? 60 00:04:07,000 --> 00:04:10,000 Let's recall what a set is from the mathematics. 61 00:04:10,000 --> 00:04:13,000 The set is a well defined collection of discrete. 62 00:04:14,000 --> 00:04:17,000 The set is a well defined collection of distinct objects. 63 00:04:18,000 --> 00:04:22,000 The set interface is a main interface for the Iraqi of containers. 64 00:04:22,000 --> 00:04:25,000 By the way, collections are often called containers. 65 00:04:26,000 --> 00:04:33,000 So set is the main interface for the hierarchy of containers that contains only unique elements that 66 00:04:33,000 --> 00:04:40,000 different implementations of the set interface during the development of JDK engineers come up with 67 00:04:40,000 --> 00:04:45,000 the decisions that they need to distinguish a collection of elements and the set of elements. 68 00:04:45,000 --> 00:04:49,000 Somehow the best decision was to introduce new interface. 69 00:04:49,000 --> 00:04:51,000 So you're of development. 70 00:04:51,000 --> 00:04:57,000 Engineers may declare variable of type set that would give us new methods to manipulate with elements 71 00:04:57,000 --> 00:04:58,000 in the container. 72 00:04:59,000 --> 00:05:04,000 But this instantly will give us the vision that this container contains only unique elements. 73 00:05:05,000 --> 00:05:10,000 To understand how implementations of the set interface work, we need to learn map interfaces first. 74 00:05:11,000 --> 00:05:13,000 We are going to understand later why. 75 00:05:14,000 --> 00:05:18,000 And now let's review one more interface Hirschi interface. 76 00:05:18,000 --> 00:05:22,000 There are a few new abstract methods were introduced here to manage the queue. 77 00:05:23,000 --> 00:05:31,000 They are offer to insert an element into the queue, remove this method to retrieve and remove the head 78 00:05:31,000 --> 00:05:32,000 of the queue. 79 00:05:32,000 --> 00:05:36,000 But in case there is an empty queue, the method throws exception. 80 00:05:36,000 --> 00:05:37,000 What is an exception? 81 00:05:38,000 --> 00:05:43,000 And a bit later we are going to learn how Java programs may handle exceptional situations of program 82 00:05:43,000 --> 00:05:44,000 execution. 83 00:05:44,000 --> 00:05:50,000 Right now you can understand exception like something what is not an expected way of program execution 84 00:05:50,000 --> 00:05:56,000 and what may potentially interrupt the program in case there is no code written that handles the exception 85 00:05:57,000 --> 00:06:03,000 for this method also retrieves and removes the head of the queue the same as remove method, but with 86 00:06:03,000 --> 00:06:09,000 only one difference in case queue is empty, there is no exception, no value is returned instead. 87 00:06:10,000 --> 00:06:17,000 Element this MassArt retrieves but doesn't remove elements from the Q the same as remove method, it 88 00:06:17,000 --> 00:06:19,000 throws exception in the case. 89 00:06:19,000 --> 00:06:19,000 Q is empty. 90 00:06:20,000 --> 00:06:27,000 Take Macit also retrieved but doesn't remove elements from the cube, with only one exception, that 91 00:06:27,000 --> 00:06:30,000 in case there is an empty cube, no value is returned. 92 00:06:31,000 --> 00:06:36,000 That's all new methods that were introduced in Q interface, no other default methods were introduced, 93 00:06:37,000 --> 00:06:44,000 cues needed when you need to implement first in, first out principle, so-called f i f o principle, 94 00:06:45,000 --> 00:06:51,000 imagine that you process support requests and you need to process them in the specific priority. 95 00:06:51,000 --> 00:06:57,000 And according to the date, when you receive them the support you get that you received the earliest. 96 00:06:58,000 --> 00:06:58,000 Exactly. 97 00:06:58,000 --> 00:07:01,000 These tickets should be processed first. 98 00:07:02,000 --> 00:07:04,000 And here you can understand what the queue is. 99 00:07:05,000 --> 00:07:11,000 The first support that was received by Q The first left in the queue. 100 00:07:11,000 --> 00:07:12,000 I feel really prepared. 101 00:07:12,000 --> 00:07:18,000 Super interesting home task for you to improve our online store and to practice your skills in writing 102 00:07:18,000 --> 00:07:20,000 use, but that will be later. 103 00:07:21,000 --> 00:07:27,000 So right now I believe you understood the three main sub Iraqis that goes right after collection interface. 104 00:07:27,000 --> 00:07:33,000 And also the structure of the next lesson should be clearer for you now during the next lesson. 105 00:07:33,000 --> 00:07:39,000 So we are going to learn each interface in detail with all methods and to learn the most popular implementation 106 00:07:39,000 --> 00:07:40,000 of each interface. 107 00:07:41,000 --> 00:07:44,000 I want you to understand, Siiri, first before we start calling. 108 00:07:44,000 --> 00:07:46,000 Believe me, this is very important. 109 00:07:47,000 --> 00:07:51,000 But very soon you would beg me to stop quoting examples, I promise you. 110 00:07:52,000 --> 00:07:54,000 Now, let's review what we have learned today. 111 00:07:55,000 --> 00:07:58,000 Today we have learned what has remained descendants of collection interface. 112 00:07:59,000 --> 00:08:03,000 Now you know why we need at least set new interfaces. 113 00:08:03,000 --> 00:08:09,000 Moreover, after this lesson, you may understand the difference between them while explaining what 114 00:08:09,000 --> 00:08:09,000 A is. 115 00:08:09,000 --> 00:08:12,000 We learned f o principle. 116 00:08:12,000 --> 00:08:14,000 Now you are ready for the next lesson. 117 00:08:15,000 --> 00:08:16,000 Thanks a lot for your attention. 118 00:08:16,000 --> 00:08:18,000 See you in the next lesson.