 Hey, everybody. This is Brian. This is our fifth video in the Java series today. We'll be discussing variables Now what are variables? Well, if you backtrack and you go back to our last few lessons You heard me talk a lot about classes how a class is a blueprint a blueprint for an object For example, let's say you have a blueprint to build a house And then when you create a house you're creating an object or an instance of that class Well, what goes into a class what goes into this blueprint? Well variables are one thing along with methods But we'll get into that in a separate tutorial So just go to Google or whatever search engine you use and type in Java primitive types Now when I say primitive I don't mean dumb they're actually pretty powerful and once again remember a lot of the documentation That you'll find out there's this Sun, but it's actually Oracle Oracle blot Sun Now I'm moving right along. What is a primitive type? Primitive types exist in all operating systems. They are the basic building blocks of most programs Unfortunately the building blocks are not the same on every operating system For example an int or an integer which we'll discuss in a minute Maybe one size on Windows and another size on Mac and another size on Linux so to avoid headaches What Java does is it says okay? These are the primitive types and they will exist equally on all operating systems So the Java platform installed on every operating system is guaranteed to be the same size So I recommend you go out and research primitive data types because we're going to go through this rather quickly But just for the sake of conversation here a bite. This is the small one Bite is an 8-bit sine twos complement integer Meaning it can go from negative 128 to positive 127. Now what does signed mean? You'll hear signed and unsigned a lot Signed means it can have a negative unsigned means it cannot have a negative But it becomes much bigger on the maximum size For example a bite unsigned I believe is 255 That'll be your homework to go research that Short short is a data type. It's 16 bit. What does this Number and bit mean? Well, that's the amount of memory. It's going to take up Two complement integer maximum value of negative or I'm sorry minimum negative 32 maximum of 32,000 Um As with you know a bite same guidelines apply you can use a short to save memory in large arrays In situations where memory saving actually matters now most modern computers have so much memory. It really does not matter Um The stable workhorse of most programs is called the int. This seems to be the favorite with most developers It's a 32 bit sine two complementary integer With a minimum value of wow look at that And a maximum value of another big number That seems to be the most popular one if you need more size, there's a long which is bigger And then you get into floating point processing, which is used in like Big big mathematic calculations, uh, 3d programming things of that with floating numbers It's called a float because the precision floats meaning you will lose precision It's really close, but it's not perfect Double is another floating point Um Basically familiarize yourself with these primitive value types Bolin is a very simple one It's a on off or a true false. It can only be true or false nothing else Uh a character What this letter c is a character It's one letter now java is unicode. What is unicode? Unicode is a standard that encapsulates literally every language in the world So you'll have English, Arabic, Japanese, etc, etc Um as a result there are 65 000 possible combinations Now some of you have worked with something called ascii before ascii is 0 through 255 Java is unicode. You should be aware of that Another thing this isn't a primitive type, but it's used quite frequently as a string What is a string? A string is a sentence like this is a string Now a string is not a primitive type. It's a class. Remember we talked about classes being blueprints Well a string is a collection of characters this care type So under the hood a string is really just a collection of these characters And they all have default values for example almost everything's set to zero You notice how this l is at the end of a long that's called a literal you're making a literal long or a literal float literal double Characters always start with the slash They also have this single quotes around them Strings can be null. What does null mean null means that the variable has not been set There's just quite literally nothing there We'll go over that in a second Booleans once again are true or false And you know once we talk about literals go out that's your homework Just find out everything you can about primitive variables Now we're going to actually work with some primitive variables here. You can see we've got a clips open We've got our our class with our main method. If you don't know what that is I suggest you rewind and watch a couple of the previous tutorials And we're going to make an int called age And how old am I? 36 Now you notice how We have this semicolon at the end here In java, you have to have a semicolon at the end of every statement This is legal. You can have your statement go several lines I think you can even do it. Yep, you can do multiple lines like this But if you want to maintain your sanity try to keep everything on one line here Now how is this structured you notice how we are declaring a type an integer A name age, and then we're setting the value to 36 Let's do another one Boolean remember, this is the light switch And we will say false Boolean can be true or false. That's it Now one thing you should notice is java is case sunset in other words if you to a capital f It still says false, but it's got this red underlined around it. Well, it's Cannot be resolved to a variable. What does that mean? It means you need to use the lower case version Same thing goes with the types of use capital B. Well I kind of lied. That's a wrapper class What is a wrapper class? A wrapper class is not like mc hammer. He doesn't go and wrap but um A wrapper class encapsulates a primitive type. In other words, it turns a primitive type a boolean in this case into an actual class So what you should be aware of is a lower case b is the primitive type An upper case b is the wrapper class I want to show you something Notice how when you type light dot you get all these things. What are all these things? Those are part of the wrapper class Now if you change this back to a lower case Hit period again nothing Okay, let's actually delete it try it. Hmm nothing Why is that? Well, that's because This is a primitive type. It's lower case. There's no extra properties here But the wrapper class has all these Values and helper methods to help you with certain things. For example, you can Let's see here. You can convert it to a string You can use weight. That's for multi-threading You can parse boolean. Otherwise, you can turn a string into a boolean and back and forth You can you can get another wrapper class out of it things love that nature. It's object oriented programming For this tutorial, let's just stick with the primitive types So you have an age 36 and a boolean of light which is false. We're saying the light is off Start and run out of time here. So I'm going to have to wrap this up and I'm just going to say what can you do with a variable? Well, we have already used the system out dot print line and say My age is plus age And we're not using the light. So you notice how As this local variable light is never red meaning it's we're never using it. It's just wasting memory So we can actually get rid of that We will run our program my age is 36 Well, I hope you found this video educational and entertaining and if you have any questions go ahead and drop me a line Once again, your homework is to go out and research java primitive types. Thank you for watching