 What happens if I want to take a data type and I want to turn it into another data type? This is actually something known as casting and all it does is basically exactly that. It tells Java that I have this one type of data type, this one thing, I want to turn it into this thing over here, this guy right here. We can see that. If we take a look at the code on the screen, one of the things that we're looking at is that I have, for example, a double. I've got a double I, 4.5. Now I want to turn that into an integer. Well one of the things that's going to happen is since we're going from a double to an integer, we're losing a little bit of our precision. Remember, doubles allow us to have decimal places and that allows for a little bit more precision. However, the integer, because it only works with whole numbers, does not. What happens is exactly this. You see, I've already kind of indicated it, but what will happen is everything passed to the right of that decimal place is going to get what is known as truncated, truncated, or completely forgotten. How do I do this? All I need to do is whatever variable I wish to cast, all I need to do is put inside of parentheses the data type I want it to become. So in this case, parentheses, or int, end parentheses. Now why do I want to do this? Well, here's an example. We take that code and let's actually apply it without casting it first. Because I've done this, what will happen is I go to attempt to compile this. If I don't change the data type, you see that I get what is known as a possible lossy conversion. This is because, again, that same idea that I was just talking about, we're going from a very precise data type, a double with percentages or with decimal places to an integer, a whole number, not so precise. So Java is just going ahead and throwing this error to tell us, hey, you're going to lose out on some information if you do this. So what I have to do is I have to go in and explicitly state, no, I do in fact want this to go from being a double into an integer. So now what happens if I want to take that integer and I want to turn it into a very precise number, a float, remember floats again are just like doubles. They allow me to have decimal places. Well, if I go through that same song and dance, I still go through the process of making my float and I give it the casting as well. What do you think this is going to turn out before you find out and pause the video and do a print statement? I'll wait. All right. So you've taken a look and you already see this, but just to confirm, if I then in turn write this out, print line, and I take a look at my K, my float that I've just created. First I compile it again because I've made changes. I see that there's nothing wrong and as soon as I run my code, what I should see is a little surprising. Notice how I don't have the .5 anymore. Well, again, if you remember when I said we changed our double to an integer, the .5 was truncated, completely thrown away. Java does not care about that .5 anymore, at least in regard to my integer J. So when I then in turn take that J and I turn it into a decimal place, remember J and integer is a whole number. When I turn it into a decimal place, it still is that whole number. And a whole number has no decimals. It's a rational number. So that's what happens when we do some casting. And this actually becomes a little bit more beneficial when we introduce one of the more interesting data types like the char, the character data type, if you will. This is a little different in the sense that we've learned already in the past that I can create strings. String str equals hello world. And you see I have just an entire sentence that's being included in there. Well, the char data type's a little different because it's known as a primitive. Strings are actually considered a little bit more advanced. The char data type simply is one key, one character with single quotations, single quotes. So you notice how my string has double quotes? The char only has one. That actually does matter. In fact, let's see what happens if I attempt to make a char with double quotes. And you can see it immediately yells at me, well, that's another yelling. Incompatible types. String cannot be converted into a char. Again, the double quotes in Java mean I'm making a string. The single quotes in Java mean I'm making a char, a character, a single letter. And one of the things that we can do with a single letter is we can actually use those augmented operators, a lot of those operators we just messed around with. So say for example, system.out.println plus plus c. Now I want you to go ahead and pause the video and actually take a stab at this. What is it going to do? Well, hopefully if you've kind of been studying up, I just introduced the pre-increment operator to my char data type. Pre-increment means that I'm going to increment it by one beforehand. And this is actually going to be a little weird because you're thinking incrementing by one, what do you mean? Well, because the char data type is primitive, it's a very basic type. Notice how when I compile my code, it does not complain. And as soon as I run it, notice how I get an I instead of an H. That's again because I'm able to work off of this. What I can actually do is I can actually cast my char data type as well, and maybe that's a little bit too much. Remember, I said we should only have one expression inside our code at any given time. So I want to take this char data type, and I want to make it a number. And now that I've done that, if I then print that number, what I'm actually getting is a 72, which, if you've set it up on your ASCII a little bit, 72 is the representation. It's the decimal notation for the letter H. If, for example, instead of C, I would do a capital A. Again, do you remember your ASCII? Well, if you don't, here's a great way to practice. The capital A is actually a 65. That's the decimal notation for capital A in ASCII. And we can mess around with these. As you can guess, if I can do this with integers, I can actually probably do this with characters as well. So in this case, say for example, I took and I casted to a char data type. Now what number should I pick? A 1, a 2, a 75, a 75. I've taken the integer, the whole number 75, and I'm going to turn it into a char data type. And what's going to happen when I compile and run this is what I should see is the ASCII notation of 75, which if we kind of are guessing, you know, if H is a 72, let's see. I, J, K.