1

00:00:01,080  -->  00:00:09,380
Let's sort of get a feature called auto boxing which is irrelevant to box produce prior to Delphi one

2

00:00:09,390  -->  00:00:16,060
had to manually create a box or two by invoking either its constructor or the value of mattered.

3

00:00:16,290  -->  00:00:17,540
We already know that.

4

00:00:18,000  -->  00:00:24,750
But in Josephite a feature called auto boxing was introduced and it's a feature of compiler as the name

5

00:00:24,980  -->  00:00:30,870
Autor boxing suggests the compiler can automatically block separate McGoo.

6

00:00:30,870  -->  00:00:37,790
That is if needed a compiler can automatically convert a parameter into the box perimeter.

7

00:00:38,280  -->  00:00:43,140
What this means is we can directly assign a perimeter to a box perimeter.

8

00:00:43,770  -->  00:00:49,740
That is where assigning a literal directly to an object reference like in the case of a string.

9

00:00:49,740  -->  00:00:56,750
Here the little quantified is assigned to an object reference and the compiler does Arto boxing that

10

00:00:56,800  -->  00:01:03,600
is it inserts the necessary code into the Java code as shown here.

11

00:01:03,600  -->  00:01:04,960
No just like other boxing.

12

00:01:04,980  -->  00:01:12,040
There is also Arto unboxing which allows a box primitive to be assigned to a primitive variable.

13

00:01:12,280  -->  00:01:14,690
He had a box but the model is assigned to.

14

00:01:14,850  -->  00:01:16,670
Variable g.

15

00:01:17,220  -->  00:01:22,460
And the compiler does auto unboxing by invoking the interview method.

16

00:01:22,940  -->  00:01:26,700
We call that we need to use our new method for unwrapping.

17

00:01:27,270  -->  00:01:35,400
So that's basically of boxing an auto unboxing videos we can not directly either put them into a data

18

00:01:35,400  -->  00:01:37,160
structure like idlest.

19

00:01:37,260  -->  00:01:39,940
Recall that this was not possible before.

20

00:01:40,500  -->  00:01:43,710
So Autobots implemented this.

21

00:01:43,710  -->  00:01:50,040
That is internally the compiler automatically converts perimeter into boxman box or do by doing something

22

00:01:50,040  -->  00:01:52,500
like this before Delphi.

23

00:01:52,560  -->  00:01:54,780
We had to do this manually.

24

00:01:54,780  -->  00:01:57,210
So what is the benefit of this.

25

00:01:57,210  -->  00:02:01,640
The code is less verbose now and it looks a lot cleaner.

26

00:02:01,810  -->  00:02:08,010
Also note that the title says metheglin location and that's because here are is a method in the class

27

00:02:08,100  -->  00:02:12,410
idlest and we are invoking it to add an element.

28

00:02:13,380  -->  00:02:16,390
Here's another example of a method invocation.

29

00:02:16,410  -->  00:02:23,280
Here we have the matter girl whose parameter is a box put him into an auto boxing variable to invoke

30

00:02:23,280  -->  00:02:23,890
it with it.

31

00:02:23,900  -->  00:02:33,770
Put him into this example demonstrates Arto unboxing here the method go has a perimeter parameter but

32

00:02:33,780  -->  00:02:41,830
do the auto unboxing variable to invoke it with the box but to C compiler is going to unwrap the boxes

33

00:02:41,940  -->  00:02:45,270
medu before making the invocation.

34

00:02:46,080  -->  00:02:46,890
You can on top of them.

35

00:02:46,890  -->  00:02:51,610
I did megacorporations directly on box primitives for example.

36

00:02:51,690  -->  00:02:57,360
Here we are creating a box perimeter and then we are incrementing it just like the VB increment primitive

37

00:02:57,480  -->  00:02:59,190
value.

38

00:02:59,220  -->  00:03:02,240
Similarly you can how Eric Maduka operations involving.

39

00:03:02,280  -->  00:03:05,730
But in order literal and a box primitive.

40

00:03:07,020  -->  00:03:10,510
Not that auto boxing does not work with Rs.

41

00:03:10,830  -->  00:03:13,150
For example this statement would be illegal.

42

00:03:13,620  -->  00:03:19,550
Let's actually look at the statement in court just to see the error message.

43

00:03:19,740  -->  00:03:21,450
Here is the exact same statement.

44

00:03:21,480  -->  00:03:24,960
So let's just go ahead and compiler.

45

00:03:26,640  -->  00:03:32,880
So I see you can see it gives a compilation error on your test incompatible types and they cannot be

46

00:03:32,880  -->  00:03:35,030
converted to integer.

47

00:03:35,280  -->  00:03:40,620
OK so this is entirely and this is in digerati under test and that it cannot be converted to degenerate

48

00:03:41,080  -->  00:03:42,010
.

49

00:03:42,490  -->  00:03:49,200
No the most likely reason for this could be that it would be very expensive to create a new array and

50

00:03:49,200  -->  00:03:55,440
then convert each element into a box primitive auto box and is an expensive operation as we will see

51

00:03:55,440  -->  00:03:57,170
in the next lesson.

52

00:03:57,170  -->  00:04:04,050
Now just imagine a method parameter that is an array of type in Biggert us OK and then some code is

53

00:04:04,050  -->  00:04:07,900
invoking the method with an array of primitives.

54

00:04:08,160  -->  00:04:15,240
So every call would require auto boxing of every element in the army and that would cause a lot of performance

55

00:04:15,240  -->  00:04:19,170
issues that support auto boxing.

56

00:04:19,220  -->  00:04:19,850
Our next move.

57

00:04:19,850  -->  00:04:24,330
Look at some potential performance issues due to auto boxing and auto unboxing
