1

00:00:02,010  -->  00:00:02,860
Hi there.

2

00:00:03,060  -->  00:00:05,090
Welcome back on this is Molinaro.

3

00:00:05,190  -->  00:00:08,200
So now we are going to do the demo for bonded.

4

00:00:08,380  -->  00:00:09,050
OK.

5

00:00:09,220  -->  00:00:14,200
And a new motor car bonded while cars husband are just in the genetics to mock us.

6

00:00:14,500  -->  00:00:14,970
OK.

7

00:00:15,120  -->  00:00:17,920
So now let's go ahead and look at the code.

8

00:00:18,090  -->  00:00:20,920
So we are going to look at this method cardless display.

9

00:00:20,970  -->  00:00:26,040
We have seen it in the lecture but did we were using bookmark as the upper bone.

10

00:00:26,100  -->  00:00:30,840
But here it is number so that display at that is a harmless method.

11

00:00:30,990  -->  00:00:34,560
All it does is displays the elements of the booklets.

12

00:00:34,560  -->  00:00:35,820
OK that's what we're doing here.

13

00:00:35,820  -->  00:00:38,700
And the for loop we are adding to the list.

14

00:00:38,940  -->  00:00:42,040
We are displaying the element each element here.

15

00:00:42,330  -->  00:00:47,550
So we are using this excellence key what God gives us the flexibility to invoke it with either a list

16

00:00:47,550  -->  00:00:53,150
of number or list of any type of number like in this tough interger.

17

00:00:53,190  -->  00:01:01,560
OK so now because the bonus number we can also invoke one of the methods of it directly and we won't

18

00:01:01,560  -->  00:01:02,970
have any Schuss.

19

00:01:03,240  -->  00:01:09,870
So this is a harmless scenario and so we need to work cut on the invariant property and this gives us

20

00:01:09,870  -->  00:01:11,220
that flexibility.

21

00:01:11,520  -->  00:01:15,630
And this is a producer off the know that extends only produces data.

22

00:01:15,720  -->  00:01:19,520
So if we try to consume data then we get decomposition.

23

00:01:19,980  -->  00:01:26,670
You are limited in dentally uses the argument that uses the class level type parameter.

24

00:01:26,760  -->  00:01:29,010
So because of that we cannot do this.

25

00:01:29,010  -->  00:01:33,720
Only thing is we can argue we can pass a null value so we can do that.

26

00:01:33,720  -->  00:01:38,310
Now if I make this super It means that it can consume data.

27

00:01:38,710  -->  00:01:39,280
OK.

28

00:01:39,480  -->  00:01:42,840
You know with the uncommon this we won't have the compilation error anymore.

29

00:01:42,960  -->  00:01:46,610
So that is fine because it is consuming data.

30

00:01:46,980  -->  00:01:52,890
But here we are getting a compilation error on that because here the pipe is number OK it is fine if

31

00:01:52,890  -->  00:01:59,070
we pass a list off number but we know that this kind of super It can also be passed is supertype like

32

00:01:59,160  -->  00:02:00,380
a lost object.

33

00:02:00,660  -->  00:02:02,630
OK so that element would be object.

34

00:02:02,700  -->  00:02:06,020
So if we make this object here then we are good.

35

00:02:06,720  -->  00:02:12,630
But we we should not be come's producing that also could not produce data should only consume data as

36

00:02:12,630  -->  00:02:14,400
we have seen in that recommendation.

37

00:02:14,400  -->  00:02:16,800
So we should not be doing that.

38

00:02:16,830  -->  00:02:21,160
So here are two year back.

39

00:02:21,540  -->  00:02:25,410
So let me just go ahead and grandis go back.

40

00:02:25,410  -->  00:02:30,720
So we are looking at twice here once here passing a list on and dejour unwanted stuff.

41

00:02:30,930  -->  00:02:31,840
So if you run it.

42

00:02:32,190  -->  00:02:36,600
So its husbanding the end granules and then it is printing the double on use.

43

00:02:36,680  -->  00:02:37,200
Okay.

44

00:02:37,380  -->  00:02:39,490
So that's the nice thing.

45

00:02:39,600  -->  00:02:46,680
And one more thing is the scene Mattel can also be represented and this meant using a genetic method

46

00:02:46,700  -->  00:02:46,850
.

47

00:02:46,980  -->  00:02:48,950
Okay here is the genetic method.

48

00:02:49,200  -->  00:02:54,350
So it can be done in that we set it up as introductory.

49

00:02:54,390  -->  00:02:59,480
So here this is not a genetic matter it is just a bicarb type only a wild card type is being used because

50

00:02:59,480  -->  00:03:01,710
there is no type parameter here as we can see.

51

00:03:01,980  -->  00:03:07,890
But this one it just does the same thing here the type barometer extends a number and we are using a

52

00:03:07,890  -->  00:03:13,620
list of B and we are still in the aliments and it will give us the exact same book.

53

00:03:13,620  -->  00:03:19,650
You can try it out later when the thing is here we have a compilation error because this boater duplicate

54

00:03:19,670  -->  00:03:25,280
methods on thats because it is it at runtime but on time all this GeneDx examination will be will be

55

00:03:25,300  -->  00:03:25,790
removed.

56

00:03:25,830  -->  00:03:31,820
So all of this will be to more on both of them are the exact same methods so they are not there it's

57

00:03:31,890  -->  00:03:35,270
not method overloading were discarded earlier or.

58

00:03:35,370  -->  00:03:37,620
So I mean just common this out.

59

00:03:37,800  -->  00:03:44,040
The only thing is you might ask which of the two approaches should be used and that we will see later

60

00:03:44,040  -->  00:03:44,070
.

61

00:03:44,070  -->  00:03:50,820
But the main thing is if the type but amygdala is used only once here in the method declaration then

62

00:03:50,850  -->  00:03:57,280
this is before it but if it is used multiple times let's say once in the return type and once here or

63

00:03:57,390  -->  00:04:03,270
so only in the multiple times only in the matter parameterless then it would go for a genetic method

64

00:04:03,290  -->  00:04:03,440
.

65

00:04:03,570  -->  00:04:04,090
OK.

66

00:04:04,230  -->  00:04:11,240
Because you can reuse this so there is a dependency between in the in the matter declaration dependency

67

00:04:11,350  -->  00:04:16,770
across in the method declaration across the method parameters on that it and BYB are just the method

68

00:04:16,770  -->  00:04:19,350
parameters because it's being reused here.

69

00:04:19,350  -->  00:04:24,110
So that's why you want to do it but if it is used only once then this is not how but later at the end

70

00:04:24,150  -->  00:04:28,380
of the lecture we will also look at some brief notes on that.

71

00:04:28,650  -->  00:04:37,520
So that's not so let's go back to me on Coman this woman to come here.

72

00:04:37,560  -->  00:04:41,720
So here we are invoking this agregate with you momentarily.

73

00:04:41,760  -->  00:04:45,740
So basically I could get to be looked at the aggregate regarding the previous wissen.

74

00:04:45,780  -->  00:04:48,880
So here you're passing the list into list and a list.

75

00:04:49,230  -->  00:04:55,470
And we are also passing a nominalist which is declared here iron all the elements from both these lists

76

00:04:55,530  -->  00:04:58,210
are added into the nominalist so we're good at getting it.

77

00:04:58,320  -->  00:05:04,340
So if we go here to get with consumer on here is the aggregate method which we have seen earlier but

78

00:05:04,340  -->  00:05:09,330
there we used a genetic Mettler this was from the bottom of the previous demos.

79

00:05:09,390  -->  00:05:12,990
So we are using most wanted list on list.

80

00:05:13,200  -->  00:05:14,320
The only thing this year.

81

00:05:14,380  -->  00:05:16,020
Everything is off seemed.

82

00:05:16,300  -->  00:05:17,990
But here because.

83

00:05:18,120  -->  00:05:23,160
Because we are doing it this way we can how we can pass different types of elements.

84

00:05:23,160  -->  00:05:26,760
So L-1 for anyone we can pass a list of integer.

85

00:05:26,940  -->  00:05:31,880
And for that we can pass and this stuff double or whatever it is.

86

00:05:31,890  -->  00:05:36,490
So here it is a generic Mathare as you can see that is a pipe barometer.

87

00:05:36,810  -->  00:05:43,440
And this is an upper bonded wild card but the ball is either here or the bone is the iron.

88

00:05:43,460  -->  00:05:45,210
Here we are using.

89

00:05:45,250  -->  00:05:47,890
We are assuming that the torso we are using is super.

90

00:05:47,880  -->  00:05:49,590
Here are the stupid Amato's.

91

00:05:49,590  -->  00:05:51,190
It is excellence.

92

00:05:51,310  -->  00:05:57,240
Ken here we are adding the elements and do all three costarring L-1 elements than any two elements.

93

00:05:57,250  -->  00:05:59,210
By looking at all the material.

94

00:05:59,520  -->  00:06:02,650
So we are consuming data on how super is used here.

95

00:06:02,640  -->  00:06:09,150
So again I named it as agregate with concealer because if we do not do that then we get a duplicate

96

00:06:09,320  -->  00:06:10,990
both of them would be deep or duplicate.

97

00:06:11,010  -->  00:06:12,760
I just named this as aggregate.

98

00:06:13,020  -->  00:06:19,250
So let's go back and let's just run it around here that is the nominalist.

99

00:06:19,360  -->  00:06:21,630
So it has all the six elements.

100

00:06:22,530  -->  00:06:30,790
Now I'm in here you have the same method can also be expressed using genetic markers.

101

00:06:30,900  -->  00:06:33,850
So most of the methods can be exposed in this way.

102

00:06:34,020  -->  00:06:42,510
In this case we are using the tree which is this fun for the consumer and even is extending E3 and also

103

00:06:42,510  -->  00:06:46,270
is extending E3 but E3 is being used only once here.

104

00:06:46,290  -->  00:06:48,220
So I think this is portable.

105

00:06:48,330  -->  00:06:50,140
This is preferable about using the wild card.

106

00:06:50,180  -->  00:06:52,400
Does this approach is profitable.

107

00:06:52,500  -->  00:06:57,660
I know it is also much more clear because this is the exchange and this is excellence and this is super

108

00:06:57,680  -->  00:06:58,060
.

109

00:06:58,440  -->  00:07:01,060
So it is much more crowded also.

110

00:07:01,180  -->  00:07:08,820
So this is a profitable approach for this because that type element is not being used here is not being

111

00:07:08,820  -->  00:07:11,810
used more than once here and this is okay.

112

00:07:11,880  -->  00:07:13,000
So.

113

00:07:13,730  -->  00:07:15,150
So lets go back.

114

00:07:15,150  -->  00:07:21,990
So thats what that non-intellectual you also get some commonly used methods from collections.

115

00:07:22,110  -->  00:07:24,400
Let's look at some of them here.

116

00:07:24,420  -->  00:07:28,990
So one of them is at Ohlemacher iron.

117

00:07:29,130  -->  00:07:36,150
We know that at all amateur basically and the elements here in the collection and we're using super

118

00:07:36,150  -->  00:07:36,840
for that.

119

00:07:37,020  -->  00:07:39,720
So this is the method from the Collections class.

120

00:07:39,730  -->  00:07:44,920
So this is the all and we are passing through in Google use here and we are adding them into this other

121

00:07:45,000  -->  00:07:46,570
list off object.

122

00:07:46,640  -->  00:07:53,150
Marjorie Howard or it IX's the pipe is in the pipe in Ford is in danger.

123

00:07:53,380  -->  00:07:58,650
And here we are having the lower Bonner's integer and integer here.

124

00:07:59,740  -->  00:08:08,610
So that's sort it is so because lower bonus because the lower bar is integer we can pass a collection

125

00:08:08,620  -->  00:08:11,580
of integer or a collection of object.

126

00:08:12,450  -->  00:08:15,760
So that's what we are doing we are passing a list of object.

127

00:08:15,750  -->  00:08:24,190
So basically the the type argument are used is the most specific subtype across the type arguments.

128

00:08:24,190  -->  00:08:26,640
So this is object indeed on an Dejah.

129

00:08:26,820  -->  00:08:36,130
So because we are using super head smartly they used the integers as the argument against the pipe argument

130

00:08:36,280  -->  00:08:36,450
.

131

00:08:36,630  -->  00:08:39,250
So they use the most specific.

132

00:08:39,750  -->  00:08:45,660
Now copy as copies from the dhaba here from the second but go to source in this list.

133

00:08:45,660  -->  00:08:49,260
So copy would copy everything and this and get that image.

134

00:08:49,280  -->  00:08:56,210
So from the starting from zero to lament it would copy everything and go into the same index positions

135

00:08:56,230  -->  00:08:56,440
.

136

00:08:56,640  -->  00:09:04,210
And if this list happens to be a bigger slice then all the remaining elements after the elements are

137

00:09:04,200  -->  00:09:06,470
copied from here will be retained.

138

00:09:06,510  -->  00:09:09,870
OK they they will have the same values as this.

139

00:09:10,600  -->  00:09:12,450
Let's look at the matter here.

140

00:09:12,580  -->  00:09:18,540
OK so this is super because it's consuming data on sources externes we look at that.

141

00:09:18,970  -->  00:09:20,930
And once again it's a genetic McChord.

142

00:09:20,940  -->  00:09:24,420
So we go back Howard on it.

143

00:09:24,630  -->  00:09:30,200
So you're passing a double list on a list so that type in court isn't up and it's more specifics update

144

00:09:30,390  -->  00:09:30,880
.

145

00:09:31,120  -->  00:09:34,740
And here we are just simply printing the last of the copy operation.

146

00:09:34,750  -->  00:09:37,670
And the third one is that this joint operation which we have also seen.

147

00:09:37,770  -->  00:09:45,000
So we are passing disjoined both the Los Angeles on the list and it uses an unbonded Why not simply

148

00:09:45,000  -->  00:09:50,280
print and go to accrue if the if there are no common elements between the two options.

149

00:09:50,460  -->  00:09:51,730
It's an unwonted.

150

00:09:52,060  -->  00:09:56,030
Because we really don't care what the pipe is in here and disposed on here.

151

00:09:56,130  -->  00:09:57,300
In the past.

152

00:09:57,510  -->  00:09:59,370
So I me run this.

153

00:09:59,380  -->  00:10:05,250
So here we are after the copy operation all the elements are copied at the beginning.

154

00:10:05,590  -->  00:10:09,270
But the nominalist also had some double elements here.

155

00:10:09,500  -->  00:10:09,810
Okay.

156

00:10:09,850  -->  00:10:11,040
The last three elements.

157

00:10:11,190  -->  00:10:17,680
So they are retained as it is and they design and operation here as a dining group because one is an

158

00:10:17,670  -->  00:10:22,510
interest on one is a double list so you cannot have any common elements.

159

00:10:22,710  -->  00:10:31,420
So that's not and we also to replace Mathare if you recall now for the replacement there I end or just

160

00:10:31,420  -->  00:10:35,770
a simple replace method which is pretty much like the replace method and the replace all method in the

161

00:10:35,770  -->  00:10:36,590
collections.

162

00:10:36,820  -->  00:10:39,320
So all that is doing is go back.

163

00:10:39,340  -->  00:10:46,800
This is the matter Qurei bliss all this is a generic method but there is also a question here which

164

00:10:46,810  -->  00:10:51,470
uses the super but replace all book producing and consuming data.

165

00:10:51,550  -->  00:10:52,830
So it should be like this.

166

00:10:52,840  -->  00:10:53,410
OK.

167

00:10:53,620  -->  00:10:56,870
Now let's let's just serialist.

168

00:10:56,910  -->  00:10:58,550
So this in this list.

169

00:10:58,840  -->  00:11:04,310
So this is all value on this is the new value and the old values present we need to replace it.

170

00:11:04,510  -->  00:11:08,710
So let me just move back.

171

00:11:08,860  -->  00:11:15,920
So here is the list and we are saying or replace all the values of eleven point forty four.

172

00:11:16,180  -->  00:11:21,190
So there are two instances seven point eleven point five on here on it.

173

00:11:21,220  -->  00:11:23,710
It is printing again with 44.

174

00:11:24,040  -->  00:11:29,890
OK Art but replace all the math and I just want to show you that it can also be done in this way like

175

00:11:30,700  -->  00:11:32,070
using a wildcard type.

176

00:11:32,170  -->  00:11:38,900
OK with this thing a lot wanted card type but you shouldn't be doing this in this case it is fine because

177

00:11:38,960  -->  00:11:43,820
you are using only the equals method and the object.

178

00:11:44,050  -->  00:11:52,270
But if this happens to be something like a bookmark or a number then and if you using some methods specific

179

00:11:52,270  -->  00:11:58,950
to that lower bone then we can run into cross-current exceptions because it can also be passed a number

180

00:11:58,990  -->  00:11:59,300
.

181

00:11:59,470  -->  00:12:04,190
In this case it is fine because we're only using the term object.

182

00:12:04,230  -->  00:12:06,360
Equals is a matter Klym object.

183

00:12:06,850  -->  00:12:12,700
But as we said if we are both producing and consuming data then we need to use eques then we need to

184

00:12:12,700  -->  00:12:13,820
use equal match.

185

00:12:13,960  -->  00:12:18,900
Here we're producing the data on here using the segment that we are consuming data.

186

00:12:19,420  -->  00:12:22,700
So that's about that.

187

00:12:22,750  -->  00:12:28,600
And finally here is yet here I just wanted to show this.

188

00:12:28,600  -->  00:12:30,020
This is an idealist.

189

00:12:30,190  -->  00:12:32,640
So this is one way in which our eldest is using it.

190

00:12:32,650  -->  00:12:40,360
So this is a constructor and an idealist is taking this collection and copies all elements of this collection

191

00:12:40,450  -->  00:12:41,880
into the audience.

192

00:12:42,310  -->  00:12:48,670
We are using extents but e is actually the barometer of the cost the cost of that parameter.

193

00:12:48,670  -->  00:12:48,950
OK.

194

00:12:48,970  -->  00:12:50,320
So this again.

195

00:12:50,410  -->  00:12:55,860
So in this case because of that the the number is the class level type parameter.

196

00:12:56,140  -->  00:12:56,640
OK.

197

00:12:56,710  -->  00:13:00,760
But we can also pass a list of integer.

198

00:13:00,990  -->  00:13:07,690
OK a list of indigenes can be passed because here the matter is this extents number right.

199

00:13:07,700  -->  00:13:13,050
It says excellence member you could be number because a number is being passed as type argument.

200

00:13:13,420  -->  00:13:19,350
And if it is number which means that we can also invoke this constructor using a collection or number

201

00:13:19,360  -->  00:13:23,180
or any updates on that's what we are doing here.

202

00:13:23,200  -->  00:13:26,400
So I bonded wild card is helping us do that.

203

00:13:26,410  -->  00:13:28,150
So this is just an example.

204

00:13:28,180  -->  00:13:29,810
So that's about it for now.

205

00:13:29,890  -->  00:13:32,860
And this court is available in the resources section.

206

00:13:32,860  -->  00:13:40,090
Let me also just discuss a little bit about how when to use Spight type barometers versus who are you

207

00:13:40,090  -->  00:13:42,000
carps which we also discussed earlier.

208

00:13:42,250  -->  00:13:44,940
But you have to look at critically a bit more.

209

00:13:45,280  -->  00:13:53,410
So let's say there were some sites not okay like we discussed earlier many methods can be declared using

210

00:13:53,530  -->  00:13:56,330
just wild cards are using generic methods.

211

00:13:56,620  -->  00:14:00,190
So the question is which of the two approaches should we play for.

212

00:14:00,280  -->  00:14:05,590
We should go for genetic matter of the same type Hamacher appears multiple times in the method declaration

213

00:14:06,220  -->  00:14:13,060
but does dependency exist and long pipes off one or more Meklit parameters and are then you can.

214

00:14:14,050  -->  00:14:19,470
For instance in the automatic Collections class same type but I'm eager It appears more than once.

215

00:14:19,510  -->  00:14:21,390
Among the parameters.

216

00:14:21,730  -->  00:14:24,340
So far this genetic matter it is appropriate.

217

00:14:24,940  -->  00:14:27,760
Similarly here is another method from the collections class.

218

00:14:27,790  -->  00:14:30,950
She had also the same type parameter appears more than once.

219

00:14:31,150  -->  00:14:39,060
As part of the method return type and once as part of the motet parameter but of the same type parameter

220

00:14:39,120  -->  00:14:41,880
is not going great at multiple times then go forward.

221

00:14:41,920  -->  00:14:48,690
What else is there to Cinematheque which we have seen earlier under-equipped the best dirt using a white

222

00:14:48,700  -->  00:14:53,740
wildcard as a type parameter would have appeared only once.

223

00:14:53,740  -->  00:14:59,500
Finally this is a disappointment there from the collections class which we have seen earlier this also

224

00:14:59,650  -->  00:15:01,380
unbonded wild card is better.

225

00:15:01,570  -->  00:15:05,760
And this gives book collections can have different types of elements.

226

00:15:05,950  -->  00:15:12,910
So if we a person using a genetic method B would have to use different parameters put a beating on me

227

00:15:12,950  -->  00:15:15,090
once in them at the declaration.

228

00:15:15,100  -->  00:15:17,730
So wildcard is the way to go.

229

00:15:18,340  -->  00:15:19,430
So that's about it.

230

00:15:19,480  -->  00:15:22,250
I hope you enjoyed learning about Willcocks.

231

00:15:22,370  -->  00:15:25,320
It should help you to write better library code.

232

00:15:25,510  -->  00:15:26,500
Thank you.
