1

00:00:00,950  -->  00:00:03,500
High they are not asked to have them all off.

2

00:00:03,510  -->  00:00:08,500
What we learned in the previous mess and so forth does them all a new class called JENNETT extra more

3

00:00:08,520  -->  00:00:13,340
has been created in the package column Dawk semantics quare.generics.

4

00:00:13,350  -->  00:00:17,140
OK now here is the main class on we are going to fill.

5

00:00:17,470  -->  00:00:22,290
So in the last lesson the Lubet agenda in is called Ask container.

6

00:00:22,470  -->  00:00:27,950
And we also saw that there was a generic class called store which implements container.

7

00:00:27,960  -->  00:00:33,270
So let's just go ahead and do that Fossel Let's create those generic types Husna to create a generic

8

00:00:33,270  -->  00:00:35,910
interface and Bynner created here

9

00:00:38,880  -->  00:00:40,220
and type B

10

00:00:43,950  -->  00:00:47,400
can also be what element but that's fine.

11

00:00:48,250  -->  00:00:49,560
And so that's the container

12

00:00:50,610  -->  00:00:58,420
.

13

00:01:03,910  -->  00:01:07,430
So you see this a

14

00:01:11,730  -->  00:01:16,620
and it's also right to get your return type would be geg

15

00:01:21,360  -->  00:01:21,760
set.

16

00:01:21,810  -->  00:01:24,660
So those are the two genetic types.

17

00:01:24,660  -->  00:01:28,550
Now let's go ahead and instantiate store.

18

00:01:28,770  -->  00:01:36,010
I'm Fussell let's create a stored off strength that storm strength sisig can dinner that have inspired

19

00:01:36,100  -->  00:01:41,140
be dinner because that's the interface and we need to do an interface.

20

00:01:41,140  -->  00:01:49,470
We know that going string store and let's use that diamond notation so that that type is automatically

21

00:01:49,470  -->  00:01:49,980
inferred

22

00:01:54,180  -->  00:01:59,350
shaila and that's printed code space.

23

00:01:59,510  -->  00:02:06,030
Be this not getting on this.

24

00:02:06,650  -->  00:02:09,140
Prince giallo OK.

25

00:02:09,630  -->  00:02:10,890
So that's what we have.

26

00:02:11,190  -->  00:02:16,710
And we know that genetics gives us the advantage of compile time by periphery.

27

00:02:16,800  -->  00:02:18,630
Right.

28

00:02:18,630  -->  00:02:23,440
So let's just go and cried to an integer here.

29

00:02:24,440  -->  00:02:31,320
And as you can see it says the Methot sex string in that type can a string is not applicable for the

30

00:02:31,320  -->  00:02:32,700
arguments.

31

00:02:33,180  -->  00:02:38,330
OK so it is giving us a compilation error right here at compilation time.

32

00:02:38,520  -->  00:02:43,480
OK so that's the main benefit of genetics right.

33

00:02:43,790  -->  00:02:51,390
It is commonly taught now that's created since it is genetics.

34

00:02:51,390  -->  00:02:57,600
We can create another instance of store but with the different type argument.

35

00:02:58,130  -->  00:03:02,030
So let's make it string sort of integer.

36

00:03:02,410  -->  00:03:04,160
That's called it.

37

00:03:04,860  -->  00:03:10,490
Do your store get in the mood got

38

00:03:14,070  -->  00:03:17,490
it run this is going to print one.

39

00:03:17,770  -->  00:03:18,390
OK.

40

00:03:18,780  -->  00:03:25,630
Now let's create a slightly more complicated instance.

41

00:03:26,370  -->  00:03:40,600
Let's make this list of integer k shift all its import data and its consciousness store.

42

00:03:40,930  -->  00:03:47,170
And once again the type is automatically inferred here and let's call it let's draw or

43

00:03:50,690  -->  00:03:52,540
not set.

44

00:03:53,100  -->  00:04:10,160
Let's use our Ariz class say eyes lest one do tree k and let's just say let's store not get here and

45

00:04:10,170  -->  00:04:14,470
this is going to print 1 2 and 3.

46

00:04:14,510  -->  00:04:15,070
OK.

47

00:04:15,420  -->  00:04:20,070
So that's how we can create instances.

48

00:04:20,070  -->  00:04:22,280
Now you might have a question.

49

00:04:22,320  -->  00:04:25,620
So what exactly is happening under the hood.

50

00:04:25,800  -->  00:04:31,390
Is it going to somehow create three instances of store for these three.

51

00:04:31,910  -->  00:04:37,700
I mean three start store process for when we are working with these different arguments.

52

00:04:37,710  -->  00:04:38,330
OK.

53

00:04:38,610  -->  00:04:46,290
Three store classes or is it simply creating store instances but somehow in the store instance you know

54

00:04:46,380  -->  00:04:48,200
the type would be string.

55

00:04:48,210  -->  00:04:51,870
In this case and in this case the object what how.

56

00:04:51,870  -->  00:04:55,110
Integer as the type for those variables here.

57

00:04:56,220  -->  00:04:59,560
OK and in this case it could be left off in two years.

58

00:04:59,620  -->  00:05:04,740
So we might guess if something like that is happening but that's not happening.

59

00:05:04,860  -->  00:05:12,650
OK so what is going to happen as a feature cart type eraser is being used here.

60

00:05:13,120  -->  00:05:20,800
And if you recall we said that Gen X is up your compile time concept which means that Gen X does not

61

00:05:20,800  -->  00:05:22,840
apply at runtime at runtime.

62

00:05:22,830  -->  00:05:25,220
There is no generates I don't care.

63

00:05:25,260  -->  00:05:26,720
And what does that mean.

64

00:05:26,740  -->  00:05:33,010
It means that the compiler basically uses this feature called Fraizer.

65

00:05:33,260  -->  00:05:33,740
OK.

66

00:05:33,780  -->  00:05:40,780
And as the name suggests it is going to it is that type C compiler is going to remove this type.

67

00:05:40,880  -->  00:05:43,110
OK so in this case it's a pipe argument.

68

00:05:43,260  -->  00:05:49,440
It's going to strip off this and it's just going to write as if this thing is not there and get a bite

69

00:05:49,440  -->  00:05:50,330
code.

70

00:05:50,500  -->  00:05:58,230
Similarly here also in this generic types since we are saying pipe eraser It is going to remove this

71

00:05:58,860  -->  00:05:59,980
type.

72

00:06:00,120  -->  00:06:06,120
OK and same here also it's going to strip this off and it's going to erase this off.

73

00:06:06,150  -->  00:06:07,960
That's why it's called IP razor.

74

00:06:08,070  -->  00:06:11,050
And for this be it were replaced by object.

75

00:06:11,070  -->  00:06:13,720
In this particular case here also object.

76

00:06:13,750  -->  00:06:15,300
See here.

77

00:06:15,390  -->  00:06:18,190
OK it's going to replace it object.

78

00:06:18,190  -->  00:06:23,880
Next we will also look at something called bonded parameters on there.

79

00:06:23,880  -->  00:06:30,960
This beacon extends some other glass in which case the clasp can be written here in this case you can

80

00:06:30,960  -->  00:06:36,030
think that the extents object in fact be extents object in this case internally.

81

00:06:36,030  -->  00:06:37,800
So it would replace that object.

82

00:06:37,810  -->  00:06:43,260
But if we extend something else then that would be stored here but that people look at it easier.

83

00:06:43,380  -->  00:06:47,010
But basically Typee treasure is that's all there is to type in Asia.

84

00:06:47,230  -->  00:06:49,040
So that's one thing that is going to happen.

85

00:06:49,060  -->  00:06:56,110
It's going to raise the type from both the parameterize types as well as from the type barometers.

86

00:06:56,130  -->  00:06:58,800
So it really object everything will be object here.

87

00:06:59,000  -->  00:07:05,400
And this whole thing will be stripped off but so this thing will also get stripped off.

88

00:07:05,670  -->  00:07:13,080
But here when we are getting in working to get the dirt get met that is going to return an object because

89

00:07:13,480  -->  00:07:16,880
here this is going to be replaced by object.

90

00:07:17,110  -->  00:07:23,050
And even the get out here is going to done an object since we are going to do it in an object.

91

00:07:23,380  -->  00:07:27,870
But in this particular invocation statement a string is being expected.

92

00:07:27,940  -->  00:07:37,980
So the the compiler would insert a cast here it would insert a string here like this and it would insert

93

00:07:37,990  -->  00:07:39,070
an integer here.

94

00:07:39,220  -->  00:07:42,570
I know over here it would insert a list of integer.

95

00:07:42,830  -->  00:07:45,520
OK so the compiler is going to do that.

96

00:07:45,570  -->  00:07:47,860
So compiler is doing two things.

97

00:07:47,910  -->  00:07:52,880
It is going to erase off all the pipes all the generics notations.

98

00:07:53,070  -->  00:07:56,490
And it is going to explicitly insert gas.

99

00:07:56,630  -->  00:07:57,280
OK.

100

00:07:57,570  -->  00:08:00,180
But for us the advantages the court is looking clean.

101

00:08:00,420  -->  00:08:06,420
But the court will not be that clean because it's going to insert gas and that is a magic pipe that

102

00:08:06,500  -->  00:08:08,660
compiler is doing for us.

103

00:08:08,700  -->  00:08:11,420
So that is what is going to happen under the hood.

104

00:08:11,910  -->  00:08:16,780
So all the pipes are getting erased and also costs are being inserted.

105

00:08:16,770  -->  00:08:18,670
That's how it's going to work.

106

00:08:18,660  -->  00:08:19,770
It might be confusing.

107

00:08:19,770  -->  00:08:21,430
Definitely it would be confusing.

108

00:08:21,490  -->  00:08:24,940
But that's on as happening with under the hood.

109

00:08:25,080  -->  00:08:25,320
OK.

110

00:08:25,320  -->  00:08:26,900
That S-type eraser.

111

00:08:27,450  -->  00:08:31,310
But we will look at Tipler later also towards the end of the chapter.

112

00:08:31,600  -->  00:08:34,430
But I think it will give you a good idea.

113

00:08:34,500  -->  00:08:39,450
That's why I wanted to discuss it now so that you would know what is actually happening under the hood

114

00:08:39,470  -->  00:08:39,740
.

115

00:08:39,920  -->  00:08:40,330
OK.

116

00:08:40,530  -->  00:08:46,030
Now there is a restriction that we also discussed about one of the restrictions was doc type argument

117

00:08:46,020  -->  00:08:47,400
can not be primitive.

118

00:08:47,670  -->  00:08:52,100
So let's try that out.

119

00:08:54,660  -->  00:08:57,120
Now as you can see we get a compiler error.

120

00:08:57,380  -->  00:08:58,020
OK.

121

00:08:58,260  -->  00:09:00,200
So that's not possible.

122

00:09:00,930  -->  00:09:09,270
And there was also a second restriction that we looked at that says that type parameter cannot be used

123

00:09:09,270  -->  00:09:10,940
in a static context.

124

00:09:11,010  -->  00:09:11,900
Right.

125

00:09:12,000  -->  00:09:20,610
So if you go here and if we make this Dodik it's going to get a compilation error cannot make a start

126

00:09:20,740  -->  00:09:23,710
reference to the non-static type.

127

00:09:24,270  -->  00:09:25,470
So that's what it is.

128

00:09:25,470  -->  00:09:27,230
So you cannot even do that.

129

00:09:27,750  -->  00:09:30,950
So those are the two restrictions that we have.

130

00:09:31,920  -->  00:09:39,490
And one other thing with this subtyping is sometimes you can if you want to you can also let's say if

131

00:09:39,550  -->  00:09:48,340
you want to make this a string then in that case you see it says add unimplemented metrics the type

132

00:09:48,350  -->  00:09:55,110
store must implement the inherited abstract method container holstering not such string.

133

00:09:55,170  -->  00:10:01,480
So it says that we need to implement this method called set which has a parameter string.

134

00:10:01,570  -->  00:10:06,540
So the moment we change this we need to implement some new methods.

135

00:10:06,750  -->  00:10:14,540
So let's go ahead and just this and as you can see some new methods got added which have strength.

136

00:10:14,710  -->  00:10:21,790
So just because we are saying that we want to implement content offspring then that would make us implement

137

00:10:22,240  -->  00:10:23,510
these methods.

138

00:10:23,770  -->  00:10:26,810
OK so that's what it is.

139

00:10:26,950  -->  00:10:35,920
But if you make it contain it on string then here over here the type argument has to be either string

140

00:10:36,460  -->  00:10:40,270
or a should not be anything in which case this needs to be remote.

141

00:10:40,300  -->  00:10:42,750
In which case it just cardless the wrong type.

142

00:10:42,760  -->  00:10:45,910
It's just it just means that the argument is not there.

143

00:10:46,090  -->  00:10:52,360
So it has to be either for doctype or it has to be string just because B how can you get off string

144

00:10:52,360  -->  00:10:53,060
here.

145

00:10:53,070  -->  00:10:59,830
OK so that's the restriction that people how you can also create out just make it some other type and

146

00:10:59,830  -->  00:11:08,230
you can also try it out for instance if you make a string here condense it off string as you can see

147

00:11:08,230  -->  00:11:08,740
here.

148

00:11:08,770  -->  00:11:10,410
It gives a compilation error.

149

00:11:10,710  -->  00:11:16,270
It says cannot infer type arguments for start and that's because we are using integer rather than string

150

00:11:16,270  -->  00:11:16,760
.

151

00:11:16,870  -->  00:11:22,930
So it's got to be a string on one off its subtypes Audix it's got to be a rock pipe and we will also

152

00:11:22,930  -->  00:11:28,990
discuss it by later which is basically doesn't have any arguments but it is dangerous to do that and

153

00:11:28,990  -->  00:11:30,700
we will discuss that later.

154

00:11:30,700  -->  00:11:33,090
So just wanted to highlight that.

155

00:11:33,250  -->  00:11:43,790
So let me just go ahead and make this the very Modise auto created methods.

156

00:11:44,080  -->  00:11:46,540
So that's about what we learned earlier.

157

00:11:46,750  -->  00:11:55,000
But let's also go ahead and create a few more but I'm impressed by a few more instances just as it's

158

00:11:55,000  -->  00:12:02,490
created a list off member number as a class and the set list.

159

00:12:04,000  -->  00:12:09,510
New Order list and Khrushchev.

160

00:12:09,560  -->  00:12:20,950
Oh and and yes we can I add an ember instance of number or one off it's spazzes subprocess.

161

00:12:20,980  -->  00:12:24,230
And this is one of the subclauses integer.

162

00:12:24,250  -->  00:12:27,190
So we can do dot on that say 1.

163

00:12:27,690  -->  00:12:28,010
OK.

164

00:12:28,030  -->  00:12:34,110
So in this list are Ls to be an odd number or we can add one ifits subtype objects.

165

00:12:34,300  -->  00:12:38,870
Similarly double it is also a subtype off number.

166

00:12:39,100  -->  00:12:51,790
So you can just say double and to do OK but you cannot add anything else because we are using generics

167

00:12:51,790  -->  00:12:51,840
.

168

00:12:51,880  -->  00:12:56,710
So you cannot do something like this strain.

169

00:12:56,870  -->  00:13:03,490
And it's going to do on the compile time type safety kicks in and says you cannot do that.

170

00:13:03,700  -->  00:13:10,750
The method out of number in that type list off number is is not applicable for the argument string because

171

00:13:10,750  -->  00:13:14,110
we are passing a number here and I admit the third one now.

172

00:13:14,130  -->  00:13:17,030
Because of this it well how.

173

00:13:17,030  -->  00:13:18,550
Number Aztek type.

174

00:13:18,820  -->  00:13:24,250
And if we try to add a string object it's going to give us this combination error.

175

00:13:24,730  -->  00:13:25,260
OK.

176

00:13:25,330  -->  00:13:26,590
That's the issue.

177

00:13:26,590  -->  00:13:27,580
That's the thing.

178

00:13:27,710  -->  00:13:29,420
And that's the benefit that we have.

179

00:13:29,440  -->  00:13:32,380
But give it a bit generics.

180

00:13:32,380  -->  00:13:36,600
Now let's also do something with Arrius

181

00:13:39,730  -->  00:13:42,250
say you list off too.

182

00:13:42,280  -->  00:13:44,480
So it does list on either side.

183

00:13:45,010  -->  00:13:45,470
OK.

184

00:13:45,490  -->  00:13:52,390
So what it means is you can store any of the list implementations list as an interface and we can store

185

00:13:52,380  -->  00:14:02,600
any off its implementations and just say zero on that door New Artist.

186

00:14:02,620  -->  00:14:11,920
OK another just object is being stored at the zero position and one that can store that's a linked list

187

00:14:13,050  -->  00:14:19,530
and that is one game we can do got a whole game.

188

00:14:19,870  -->  00:14:23,220
So that's because we can store any list.

189

00:14:23,250  -->  00:14:24,010
OK.

190

00:14:24,100  -->  00:14:30,460
Now if you make this an idealist then B how.

191

00:14:30,610  -->  00:14:32,950
I mean we don't get any competition at her.

192

00:14:33,430  -->  00:14:37,210
OK what this means is we want to store only our A-list within this array.

193

00:14:37,450  -->  00:14:41,130
But we are also starting ringless but it did not give us a completion order.

194

00:14:41,320  -->  00:14:47,970
But if we run it it's going to give this or a story exception game which means that at runtime we are

195

00:14:47,980  -->  00:14:53,800
getting this exception and that's not very good because the type safety is not enforced or compile time

196

00:14:53,830  -->  00:14:54,980
but at runtime.

197

00:14:55,210  -->  00:14:55,710
OK.

198

00:14:55,840  -->  00:14:57,590
That we are going to discuss later.

199

00:14:57,730  -->  00:15:04,090
But I just wanted to just show you that if you create like an artist here or something you can store

200

00:15:04,270  -->  00:15:11,830
either that instance of doc type or I want to get subtypes but back then and then if you're trying to

201

00:15:11,830  -->  00:15:14,510
store something as we are getting a compiler error OK.

202

00:15:14,530  -->  00:15:22,660
So the error is being shown at compile time itself whereas in case of an NRA we can see that we are

203

00:15:22,650  -->  00:15:28,200
not having any issue at compile time because we are supposed to store only our oldest objects.

204

00:15:28,400  -->  00:15:30,760
And here we are storing l'Anglaise.

205

00:15:30,760  -->  00:15:38,110
But in case of an array the typesafe B is being enforced only at runtime behere the types is enforced

206

00:15:38,110  -->  00:15:40,080
at compile time in case of generics.

207

00:15:40,140  -->  00:15:47,140
But we are as it is enforced at runtime and that we will also discuss later when we are discussing invariants

208

00:15:47,130  -->  00:15:47,520
.

209

00:15:47,530  -->  00:15:49,870
But just wanted to highlight that here.

210

00:15:50,050  -->  00:15:50,980
So that's about it.

211

00:15:51,120  -->  00:15:51,690
Thank you.

212

00:15:51,730  -->  00:15:54,640
And the court is available in the resources section happy coding
