1

00:00:01,050  -->  00:00:03,440
Hi there this is they don't want to lose you.

2

00:00:03,500  -->  00:00:07,360
I know let's look at what an unbounded wild card is.

3

00:00:07,380  -->  00:00:10,880
Item number three which we saw earlier with regards to Roth pipes.

4

00:00:10,890  -->  00:00:14,500
Also discuss us about unbonded Walcott's.

5

00:00:15,360  -->  00:00:22,110
We know that a genetic bite through its type parameter indicates that it can be instantiated with an

6

00:00:22,230  -->  00:00:23,330
unknown type.

7

00:00:23,370  -->  00:00:31,260
Right here is a genetic type and it can be instantiated by using parameterized types like store of string

8

00:00:31,350  -->  00:00:39,450
or sort of integer but a parameterized type like a generic type can also indicate that each type argument

9

00:00:39,540  -->  00:00:44,660
can be an unknown type and that is done using a wildcard.

10

00:00:44,790  -->  00:00:51,870
And here is an example question mark symbol here is a white card and it can be read as store off some

11

00:00:51,870  -->  00:00:53,080
pipe.

12

00:00:53,100  -->  00:00:59,900
What this means is the met that girl doesn't know or doesn't care whether you will get with the story

13

00:00:59,900  -->  00:01:04,260
of straying or sort of double or start of integer Archstone or whatever.

14

00:01:04,800  -->  00:01:09,230
Basically parameterize stripe is being gentrified here.

15

00:01:09,240  -->  00:01:15,270
Also if you're referring to this VEIDT cart as unbonded Valcartier which means that there is also something

16

00:01:15,270  -->  00:01:19,900
called bounded by cart and we will discuss it later in a separate lesson.

17

00:01:20,790  -->  00:01:28,240
No dark wild card can be used only as a type argument so it cannot be used as a barometer.

18

00:01:28,680  -->  00:01:35,010
For instance if you use it as a pipe barometer like in this example then it would be ambiguous to veto

19

00:01:35,060  -->  00:01:39,770
the two type parameters that detached type of variable is referencing.

20

00:01:40,140  -->  00:01:48,330
So we cannot use wildcard for it by parameter not that commonly it is used just part off type of method

21

00:01:48,330  -->  00:01:55,160
parameters like in the case of method go here although it can be used in assignment statements.

22

00:01:55,170  -->  00:01:58,310
It is not common to see them being used in this way.

23

00:01:58,770  -->  00:02:04,920
Here we have stored a String instance which is assigned to a variable whose reference byte uses a wildcard

24

00:02:04,930  -->  00:02:05,420
.

25

00:02:05,940  -->  00:02:11,340
Just recall the store is a class we used in one of the earlier lessons and there's also part of the

26

00:02:11,460  -->  00:02:14,670
genetics demo class.

27

00:02:14,670  -->  00:02:20,970
One question we may have is if wildcard Jannette if I use a parameterized type then why not simply use

28

00:02:21,090  -->  00:02:28,380
object of type argument as object as the most generic class as it is a superclass of all process and

29

00:02:28,380  -->  00:02:31,710
hence can be assigned to any object.

30

00:02:31,710  -->  00:02:38,490
The limitation with using object of type argument would be that you can only assign an instance that

31

00:02:38,520  -->  00:02:41,580
also has object type argument.

32

00:02:42,200  -->  00:02:47,790
And this has to be a property called invariants which we will discuss later but it applies to not just

33

00:02:47,850  -->  00:02:53,970
object type but any type like string or integer if it is stored of string.

34

00:02:54,000  -->  00:03:02,490
You can only assign is stored of string but with white card we can assign an instance of any type that

35

00:03:02,490  -->  00:03:07,430
is storing all string Ostrov integer or anything else.

36

00:03:07,560  -->  00:03:10,970
And here is the example we saw in the previous lessons Jim on there.

37

00:03:10,970  -->  00:03:14,090
Rock pipes were used as parameters.

38

00:03:14,430  -->  00:03:19,560
You may recall that this method simply returns the number of elements that are common between the two

39

00:03:19,560  -->  00:03:21,120
in coatless.

40

00:03:21,120  -->  00:03:28,140
Only difference here and this method is that raw types are now replaced by wildcards so that this be

41

00:03:28,170  -->  00:03:32,910
once again how compile time type safety.

42

00:03:32,910  -->  00:03:38,220
Now here is an important pipe see if the restriction from the compiler when using unbonded Willcocks

43

00:03:38,940  -->  00:03:42,880
we just cannot invoke any methods on the part on the great stype.

44

00:03:43,020  -->  00:03:48,630
Were those methods use the parameter of the class in the method parameter.

45

00:03:48,720  -->  00:03:54,090
The only way we can invoke those methods is by passing a non-value as argument.

46

00:03:54,090  -->  00:03:57,170
So we cannot involve them by passing any other argument.

47

00:03:57,330  -->  00:04:01,100
And if you can't do that you get a compiler not that.

48

00:04:01,090  -->  00:04:04,200
Here we are seeing classes parameter.

49

00:04:04,470  -->  00:04:09,600
Later we will look at generic methods which can have their own parameters.

50

00:04:09,600  -->  00:04:15,330
That is methods can have pyper amateurs that are completely independent of the type that armiger declared

51

00:04:15,330  -->  00:04:16,670
at the class level.

52

00:04:17,190  -->  00:04:24,270
So this is the restriction be how it is to ensure pipes if B for instance it is the same example we

53

00:04:24,270  -->  00:04:25,180
saw earlier.

54

00:04:25,230  -->  00:04:30,930
Only difference here is the statement where we are in marking the odd matter of the list.

55

00:04:30,930  -->  00:04:37,530
This really was a compulsion at her as the add method uses sic class level type barometer for the method

56

00:04:37,550  -->  00:04:39,010
parameters parameters did.

57

00:04:40,060  -->  00:04:46,540
Just imagine compiler allowing us to quantify which is an Which I guess it would also allow us to add

58

00:04:46,660  -->  00:04:51,360
a double value with the simplest Just like in the case of a rock.

59

00:04:51,880  -->  00:04:55,320
And we once again would have the same safety issues.

60

00:04:55,610  -->  00:05:02,170
So compiler ensures that we cannot invoke such methods but it would allow us to access methods that

61

00:05:02,170  -->  00:05:09,580
did not use classloader parameters as method parameters and the condensed method in this class.

62

00:05:10,150  -->  00:05:16,930
But if you do want to access methods that method parameters that how Glass-Stegall by parameters then

63

00:05:16,930  -->  00:05:23,460
you can use generic methods or bonded wild card types both of which will be discussed later on.

64

00:05:23,470  -->  00:05:29,120
One other thing to note here is that apart from not being able to add elements to list one or list do

65

00:05:29,560  -->  00:05:35,900
we cannot also make any assumptions about the Bible objects that we can get out of them.

66

00:05:35,980  -->  00:05:40,220
We do not know whether it is a string or integer or some other object.

67

00:05:40,900  -->  00:05:46,930
If we need to know the object type then once again we need to use generic methods are bounded by the

68

00:05:46,930  -->  00:05:48,320
courts.

69

00:05:48,460  -->  00:05:50,040
We can also see this in the demo.

70

00:05:50,320  -->  00:05:53,870
So let's head over to clefs for a short demo.

71

00:05:55,240  -->  00:06:00,430
OK here we are in the genetics demo class and we are going to look at this method called just get common

72

00:06:00,430  -->  00:06:02,600
elements called wildcard.

73

00:06:02,920  -->  00:06:09,030
So in the previous animal we'll get this method get common elements caught little sticking to less list

74

00:06:09,030  -->  00:06:09,990
of strengths.

75

00:06:10,090  -->  00:06:15,310
The first one had these elements ABC and the second NBCC and all this method does as a reader and a

76

00:06:15,310  -->  00:06:17,990
number of elements that are common between the tulis.

77

00:06:18,040  -->  00:06:19,150
So it would be two.

78

00:06:19,270  -->  00:06:25,850
So this meant that I was using rock types and in this method we are using wildcards unbonded wild card

79

00:06:25,860  -->  00:06:27,780
stuff the only difference.

80

00:06:27,820  -->  00:06:28,780
So here we are.

81

00:06:28,870  -->  00:06:32,230
So we looked at the signature and the lecture to see it use it.

82

00:06:32,250  -->  00:06:35,080
It uses an unbonded wild card here.

83

00:06:35,170  -->  00:06:36,410
Everything else is same.

84

00:06:36,540  -->  00:06:39,920
And if we run it it prints the value too.

85

00:06:40,140  -->  00:06:40,640
OK.

86

00:06:40,900  -->  00:06:46,900
So when you are tempted to use rock types just because you do not know or you do not care about the

87

00:06:47,050  -->  00:06:50,930
objects and the less then you would want to use unbonded right.

88

00:06:50,920  -->  00:06:54,870
COX So that would give you the compile time type safety guarantee.

89

00:06:55,050  -->  00:06:55,790
OK.

90

00:06:56,380  -->  00:06:57,360
So let's go back.

91

00:06:57,370  -->  00:07:01,930
So that's the common way in which wild cards are used and method parameters are that are used in method

92

00:07:01,930  -->  00:07:06,840
parameters and they are not commonly used like this in assignment statements.

93

00:07:07,000  -->  00:07:11,510
So here we see how a container of some type will get counted.

94

00:07:11,530  -->  00:07:17,680
If you recall it is an interface unbe or assigning a string store so String store was created and one

95

00:07:17,680  -->  00:07:21,310
of the earlier demos here does contain on all string.

96

00:07:21,370  -->  00:07:26,660
And we are instantiating it with a store stored implements container and we are setting the value Djala

97

00:07:26,730  -->  00:07:27,110
.

98

00:07:27,490  -->  00:07:29,340
And we can also move the get method.

99

00:07:29,590  -->  00:07:35,890
So we are taking this string store not all string and we are assigning it to a container of some type

100

00:07:35,910  -->  00:07:36,150
.

101

00:07:36,390  -->  00:07:37,200
OK.

102

00:07:37,210  -->  00:07:42,880
Now once this is there we really do not know what this particular object will help.

103

00:07:42,990  -->  00:07:45,200
Ok that's why it's named some store.

104

00:07:45,340  -->  00:07:52,280
And when we get the only thing we can do is we can assign it to object because this is the supertype

105

00:07:52,360  -->  00:07:53,690
all process.

106

00:07:53,740  -->  00:07:58,970
So we can assign it to this because we really do not know what this one has because it's been at off

107

00:07:58,990  -->  00:08:00,260
some time.

108

00:08:00,550  -->  00:08:06,070
But if you for sure know that it has an object of certain type like string in this case then you can

109

00:08:06,070  -->  00:08:08,840
help string but unique or type construct here.

110

00:08:08,890  -->  00:08:09,660
So that's the thing.

111

00:08:09,660  -->  00:08:11,730
But it's not commonly used in this way.

112

00:08:11,740  -->  00:08:14,440
So here is the stored element Java.

113

00:08:15,010  -->  00:08:17,760
Now let's look at the third one which is a compiler restriction.

114

00:08:17,770  -->  00:08:23,230
So here we have to list lots of integers and it has these elements 1 2 3 and 4.

115

00:08:23,560  -->  00:08:28,790
And what we want to do as we wander past is there's less to this method called aggregate we are named

116

00:08:28,790  -->  00:08:28,910
.

117

00:08:28,960  -->  00:08:32,320
It's named as invalid aggregate because it is really invalid.

118

00:08:32,410  -->  00:08:37,960
So we're passing this nice list on here and it is still here and we want to aggregate them into this

119

00:08:37,960  -->  00:08:38,640
list.

120

00:08:38,650  -->  00:08:40,680
So there will be added into this list.

121

00:08:40,690  -->  00:08:43,430
So let's look at this method.

122

00:08:43,900  -->  00:08:46,360
So we scroll down here.

123

00:08:46,510  -->  00:08:53,900
This is the method that sonor does so these are all panoramic Rice types lists one list to unnecessary

124

00:08:53,990  -->  00:08:54,250
.

125

00:08:54,490  -->  00:09:00,340
So here we are trying to invoke the argument that on list 3 on our list one and then the second statement

126

00:09:00,370  -->  00:09:01,600
and list two.

127

00:09:01,950  -->  00:09:08,830
But the compiler is giving an error here because we cannot move these methods such methods because these

128

00:09:08,860  -->  00:09:15,910
method this method uses a class level type parameter and we know that we cannot in those matters and

129

00:09:15,910  -->  00:09:22,120
that is how the compiler is ensuring that safety came back we can invoke other methods like campaigns

130

00:09:22,210  -->  00:09:24,490
or any other method which does not use.

131

00:09:24,670  -->  00:09:28,700
It does not use class level type parameter just that we can't be we in this.

132

00:09:28,750  -->  00:09:33,940
And if you really will only mean you can invoke is by using NULL value so if you are not here you can

133

00:09:33,940  -->  00:09:36,760
see that there is no compulsion at all anymore.

134

00:09:37,520  -->  00:09:44,050
And but if you're not ok with this restriction or if you're not ok with this restriction here like this

135

00:09:44,080  -->  00:09:51,400
you really want to know what element is stored like in such cases you have to use either bounded wildcards

136

00:09:51,460  -->  00:09:53,830
or you can use generic methods.

137

00:09:53,940  -->  00:09:54,450
OK.

138

00:09:54,490  -->  00:10:00,250
Our next move will look at generic methods and we would also look at this particular method with Widger

139

00:10:00,400  -->  00:10:05,940
with generic that's where we can agree to get things set up Saunders wisdom on.

140

00:10:06,100  -->  00:10:06,500
Thank you.

141

00:10:06,500  -->  00:10:09,100
And this code is also available in the resource section.

142

00:10:09,100  -->  00:10:10,240
Happy coding.
