Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
1
00:00:05,270 --> 00:00:07,410
Okay, I thought I'd do a brief video
2
2
00:00:07,410 --> 00:00:10,210
on abstract data types because lists
3
3
00:00:10,210 --> 00:00:12,110
is the first abstract data type
4
4
00:00:12,110 --> 00:00:14,450
we're going to look at in the course.
5
5
00:00:14,450 --> 00:00:18,970
So an abstract data type isn't a concrete data structure
6
6
00:00:18,970 --> 00:00:20,890
in the sense that an array is.
7
7
00:00:20,890 --> 00:00:24,020
It doesn't dictate how the data is organised.
8
8
00:00:24,020 --> 00:00:27,150
With arrays, we know that we have to store
9
9
00:00:27,150 --> 00:00:29,460
all the items as one contiguous blah
10
10
00:00:29,460 --> 00:00:32,260
and arrays also dictate that every item in the array
11
11
00:00:32,260 --> 00:00:34,480
has to occupy the same amount of memory.
12
12
00:00:34,480 --> 00:00:37,690
So arrays are telling us how the data has to be stored
13
13
00:00:37,690 --> 00:00:39,350
but lists don't do that.
14
14
00:00:39,350 --> 00:00:42,530
Lists are more of a conceptual idea
15
15
00:00:42,530 --> 00:00:47,520
and they dictate the operations we can perform
16
16
00:00:47,520 --> 00:00:50,690
on the data set, not the items themselves.
17
17
00:00:50,690 --> 00:00:52,650
An abstract data type doesn't do something
18
18
00:00:52,650 --> 00:00:55,383
like say you can only multiply these items together,
19
19
00:00:55,383 --> 00:00:59,230
it's more that it dictates how we can access the items.
20
20
00:00:59,230 --> 00:01:01,370
Can we do random access?
21
21
00:01:01,370 --> 00:01:04,210
Can we get to the first item that we added?
22
22
00:01:04,210 --> 00:01:06,510
Can we get to the last item that we added?
23
23
00:01:06,510 --> 00:01:10,980
And so, an abstract data type is more about behaviour
24
24
00:01:10,980 --> 00:01:12,850
and what operations you can do.
25
25
00:01:12,850 --> 00:01:16,670
Now in Java, a concrete data structure like an array
26
26
00:01:16,670 --> 00:01:18,840
is usually a class.
27
27
00:01:18,840 --> 00:01:21,250
Arrays might actually be an exception to that.
28
28
00:01:21,250 --> 00:01:23,180
So you'll see as we go through the course
29
29
00:01:23,180 --> 00:01:25,180
and we look at other concrete data structures,
30
30
00:01:25,180 --> 00:01:27,710
there's usually a class for them in the JDK.
31
31
00:01:27,710 --> 00:01:29,658
When it comes to an abstract data type,
32
32
00:01:29,658 --> 00:01:33,574
normally those are interfaces, which makes sense right?
33
33
00:01:33,574 --> 00:01:36,260
Because they're not telling you how to store the data,
34
34
00:01:36,260 --> 00:01:39,270
they're specifying behaviour and that's
35
35
00:01:39,270 --> 00:01:41,100
commonly done with an interface.
36
36
00:01:41,100 --> 00:01:45,530
And so basically, any data structure can be used
37
37
00:01:45,530 --> 00:01:47,730
to implement an abstract data type,
38
38
00:01:47,730 --> 00:01:51,050
as long as you have a class that implements the interface
39
39
00:01:51,050 --> 00:01:52,830
for the abstract data type,
40
40
00:01:52,830 --> 00:01:56,800
any class can behave like that abstract data type.
41
41
00:01:56,800 --> 00:02:00,380
So in the case of lists, any class that implements
42
42
00:02:00,380 --> 00:02:02,550
the list interface, is a list
43
43
00:02:02,550 --> 00:02:04,880
and so you could have a class that uses
44
44
00:02:04,880 --> 00:02:06,690
an array for the list.
45
45
00:02:06,690 --> 00:02:08,870
If that class implements the list interface,
46
46
00:02:08,870 --> 00:02:10,510
it can be treated like a list.
47
47
00:02:10,510 --> 00:02:11,620
You could have a class,
48
48
00:02:11,620 --> 00:02:13,070
this would be a terrible thing to do,
49
49
00:02:13,070 --> 00:02:16,100
but you could have a class that has individual fields
50
50
00:02:16,100 --> 00:02:17,650
for every item in the list.
51
51
00:02:17,650 --> 00:02:21,280
As long as that class implements the list interface,
52
52
00:02:21,280 --> 00:02:22,113
it's a list.
53
53
00:02:22,113 --> 00:02:23,700
You can treat it like a list.
54
54
00:02:23,700 --> 00:02:26,100
And so when it comes to an abstract data type,
55
55
00:02:26,100 --> 00:02:28,410
they're not concrete data structures,
56
56
00:02:28,410 --> 00:02:30,970
they don't dictate how the data can be stored,
57
57
00:02:30,970 --> 00:02:34,159
but they do dictate the operations you can do
58
58
00:02:34,159 --> 00:02:36,580
on the abstract data type.
59
59
00:02:36,580 --> 00:02:39,540
So for example with lists, let's say you can add an item,
60
60
00:02:39,540 --> 00:02:40,700
you can remove an item,
61
61
00:02:40,700 --> 00:02:42,692
you can get the index of an item, et. Cetera,
62
62
00:02:42,692 --> 00:02:45,080
but they don't say and this is the way
63
63
00:02:45,080 --> 00:02:47,020
you have to store the items in the list.
64
64
00:02:47,020 --> 00:02:48,080
They don't say that.
65
65
00:02:48,080 --> 00:02:51,080
So now that we have some idea what an abstract dat type is,
66
66
00:02:51,080 --> 00:02:54,950
let's move on to looking at list in the JDK.
67
67
00:02:54,950 --> 00:02:56,500
I'll see you in the next video.
5817
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.