Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,390 --> 00:00:03,180
Many collection types implement the list interface.
2
00:00:05,060 --> 00:00:08,240
For example, Array List implements the list interface.
3
00:00:10,240 --> 00:00:14,620
Linked list implemented as well, and there are other classes that we're not going to cover.
4
00:00:17,920 --> 00:00:21,640
So in this lesson, you're going to see polymorphism from classes that implement list.
5
00:00:24,680 --> 00:00:28,970
Open the folder for this lesson by following this path in your course resources.
6
00:00:34,430 --> 00:00:39,350
Now, list is an interface that defines methods a class must implement.
7
00:00:41,150 --> 00:00:47,150
The array list class implements this interface, it also implements a bunch of other interfaces, inherits
8
00:00:47,150 --> 00:00:48,910
from a class, but we don't care about that.
9
00:00:48,920 --> 00:00:53,060
Let's just focus on the fact that array list implements the list interface.
10
00:00:57,540 --> 00:01:03,380
Here are some of the methods that list the fines, this one should be familiar to you, size array list
11
00:01:03,390 --> 00:01:04,769
implements this interface.
12
00:01:04,769 --> 00:01:08,310
So we know the array list class overrides this method.
13
00:01:08,730 --> 00:01:12,300
You can go back here and call size from this array list.
14
00:01:19,190 --> 00:01:23,360
Here's another one is empty, and it follows that we can call is empty.
15
00:01:28,690 --> 00:01:34,240
Contains a list, definitely overrides, contains, because we've used it so many times before it.
16
00:01:39,780 --> 00:01:45,240
Anyways, you get the points, the array list class implements this interface, so it's basically signing
17
00:01:45,240 --> 00:01:50,510
a contract that it's going to override all of the methods inside this interface and it does.
18
00:01:50,520 --> 00:01:54,900
For example, we know our array list is going to be forced to override array.
19
00:01:58,260 --> 00:02:02,130
Let's start to Iraq, which returns an array from the array list.
20
00:02:05,820 --> 00:02:10,710
Now, linked list is another collection type, it also implements the list interface.
21
00:02:14,030 --> 00:02:20,090
Because linked list implements list, it also signs a contract that it's going to override all of the
22
00:02:20,090 --> 00:02:21,500
methods inside list.
23
00:02:25,420 --> 00:02:31,120
We can create a linked list collection in much the same way linked list that can store energy objects
24
00:02:31,120 --> 00:02:31,750
list to.
25
00:02:33,190 --> 00:02:35,980
Is equal to a new object of the limitless class.
26
00:02:42,920 --> 00:02:48,650
And because the linked list class implements the list interface, we know it's going to be forced to
27
00:02:48,650 --> 00:02:50,330
override all of these methods.
28
00:02:52,380 --> 00:02:57,060
So all the same, we can call at least to add a lot, a few numbers.
29
00:03:08,780 --> 00:03:10,700
We can call list to size.
30
00:03:15,690 --> 00:03:17,070
List that is empty.
31
00:03:19,610 --> 00:03:21,080
List contains.
32
00:03:26,050 --> 00:03:27,370
Listen to not Iraq.
33
00:03:29,910 --> 00:03:37,320
All right, so what's the difference between a relist and linked list, performance wise linked list
34
00:03:37,320 --> 00:03:39,420
is almost always the wrong choice.
35
00:03:41,450 --> 00:03:45,050
If you look at the documentation array list is usually faster.
36
00:03:46,160 --> 00:03:52,090
Array list offers a faster way of accessing elements because it has direct references to every element,
37
00:03:52,430 --> 00:03:58,010
whereas with a linked list, it has to go through every single element in the list until it gets to
38
00:03:58,010 --> 00:03:59,930
the element that you're trying to access.
39
00:03:59,960 --> 00:04:02,900
So it's a lot slower when you're trying to access values.
40
00:04:03,110 --> 00:04:05,720
In this course, we're going to stick to using a realist.
41
00:04:08,030 --> 00:04:13,760
Now, what's interesting is that remember that interfaces allow for polymorphism because array list
42
00:04:13,760 --> 00:04:15,200
implements the list interface.
43
00:04:15,380 --> 00:04:17,720
We can declare the object type list.
44
00:04:21,700 --> 00:04:25,180
Same thing here, we can declare the linked list as type list.
45
00:04:28,530 --> 00:04:30,210
Why is polymorphism important?
46
00:04:30,450 --> 00:04:36,810
Same reason as always, flexibility, if I declare this type list, then I can easily switch between
47
00:04:36,810 --> 00:04:38,370
array list and linked list.
48
00:04:44,560 --> 00:04:50,470
I like to just stick to our list now, all I want you to take away from this lesson is that array list
49
00:04:50,470 --> 00:04:54,880
and linked list can take the form of the interface they implement.
50
00:04:58,040 --> 00:05:02,360
Let's recap array list and linked list, implement the list interface.
51
00:05:06,470 --> 00:05:10,640
List is an interface that defines method's a class must implement.
52
00:05:13,140 --> 00:05:18,930
In other words, each class signed a contract to override every method inside the lowest interface.
53
00:05:19,200 --> 00:05:21,920
Each one of them overrides these methods in a different way.
54
00:05:22,170 --> 00:05:24,840
But in general, performance was linked.
55
00:05:24,840 --> 00:05:27,210
List is almost always the wrong choice.
56
00:05:27,210 --> 00:05:29,820
In this course, we're going to stick to using a realist.
57
00:05:32,200 --> 00:05:38,140
And because each class implements the interface, we can see polymorphism, you can declare the array
58
00:05:38,140 --> 00:05:45,010
list as type list Auris type array list, and you can also declare a linked list as its own type or
59
00:05:45,190 --> 00:05:46,060
type list.
6042
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.