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