 Hey everybody, this is Brian. Today we'll be discussing wrapper classes, boxing and unboxing. So first off, let's take a step back. If you remember back from video, oh what was I believe video five? We did primitive types. And those are things, you know, like int, and then we'll just say 11. So that's an integer. We're pretty familiar with it. And you notice how when you type int, whatever the int is, and then dot, nothing happens. That's because that's a primitive type. Now, a wrapper class wraps that primitive type into an object. Oops, call it wrapper. So what we have here is you have the int and then uppercase integer. What's the difference between these two? Well, this is the primitive value. This is a wrapper class. We've discussed classes before. And basically what's going on here is we're taking that primitive and putting it inside of a class. See how we have properties now? What are all these properties? What do they do? Well, these are methods inside of the class. There's typically a wrapper class for each primitive type. Now let's just kind of explore through here and you can see there's a lot of different things you can do. For example, you can unwrap the primitive type. See int value. That's often called x value. There's like a decimal, long float, integer, boolean. It'll always have the type in front of it. So int value returns the primitive type of int. Just to kind of prove this, let's go system.out. Oops, can't type today. Print line. And what we're going to do is we're going to print out the number 12. What's going on in memory here is we are creating an instance of this wrapper class. We are boxing the primitive type of 12 inside of it. And then we're doing a system out print line and we are unboxing that primitive type using int value. So when we run this, it should print out 12. And there it does. So we have just box the value and then unboxed it. Now, that's boxing and unboxing in the nutshell. It gets much more complex than that, but we're not going to touch on it too much. But one thing you can do is called auto-unboxing. So we will say mint equal mint. Actually, let me show you a little trick here. Plus equal. And we'll say mrapper. Now what we're doing is we're taking this variable mint. And we're saying take that and add it to wrapper. So we're taking 11 plus 12. And just for for giggles here, we are going to print out the value of mint. Now once again, we have an primitive type of 11. We have a wrapper class of 12. We're going to take the primitive type. We're going to add it to the wrapper class. Now what's going to happen is this wrapper class is going to automatically unbox the primitive type of 12 and add it to mint. That's called auto-unboxing. As you see, we have 23. So you can treat these wrapper classes as their primitive types, but they have much more functionality. That's really what I want you to walk away from this little tutorial with. Now you might be asking yourself, why do you need a wrapper class? Well, wrapper classes are used all over the place specifically in collections and methods that return objects. Because remember, everything in Java is an object, except for primitive types. So you can't treat a primitive type like an object because it's not an object. Rapper classes, however, are an object. They inherit from the object tree. So you could actually say object mobj equal, and we will say wrapper. You could say we have an object called m object, which is equal to wrapper, which is 12. And then you can turn around and just say system out. I really cannot type dig a I apologize. Print line, and we are going to say int. What do you think is going to happen here? Notice how we have this nice little error. Cannot cast from object int. What's going on there? Let's try casting it to integer. Notice how the error disappears. Once again, we'll try the primitive type. We're going to cast. This is called a cast. That's when you're changing this object to something else. It says we cannot change object to int because int is a primitive type. We can, however, cast that into the wrapper class. So that's one example of why you might need this. Now, I know that was probably a little confusing. I recommend that you open Eclipse and start playing around with wrapper classes and see exactly what they can and can't do for you. Another thing you can actually do, let me kind of show you real quick here, is you can say parse. That's another way you can basically say take the string and parse it. And if it can't parse it, it'll throw an error. You can catch that error, which we'll cover in later tutorials. But for now, just play around with wrapper classes and try to get a feel for them. Once again, this is Brian. I hope you found this tutorial educational and entertaining. Thank you for watching.