‫Instructor: Hi.
‫Within this lecture we are going to continue
‫with the variables and most popular data types
‫like we have seen double, float, and integer, and long.
‫We are going to see strings and some other types as well.
‫So for example, we have seen what happens when
‫we divide double by double or integer by integer.
‫Let's create a double called pi,
‫and this will be equal to 3.14 of course
‫and let's create an integer for example
‫for our radius and calculate a circumference of a circle.
‫Okay? So for example, I have my pi, 3.14
‫I have my radius as five.
‫So do you know the equation of circumference?
‫It's two multiplied by pi multiplied by radius, right?
‫So what happens when we multiply an integer with a double?
‫Now we're gonna find out about that, aren't we?
‫Let's call System.out.println one more time
‫and try to multiply 2 by pi by r.
‫And I suggest you pause the video
‫and try to do it on your own
‫with these kind of little exercises okay?
‫So let me do it and let me run it.
‫And you will see it's 31.4,
‫so don't worry about this 000002 things
‫like if it's a very small decimal
‫it's not your fault, it's just how actually
‫Android handles how Java handles the decimals.
‫So it's not very important.
‫It won't mess with your calculations in real life examples
‫but as you can see we got a double out of this.
‫So we got 31.4 as we expect.
‫So if we just multiply a double by an integer as
‫as we would expect, it gives out the result as a double
‫and it's actually better for us because we can
‫see the decimals at this point.
‫So if you need decimals, make sure you are working
‫with doubles, at least in a single parameter
‫of an equation like this so that you can get
‫specific results out of that.
‫So let me move on to some other examples from here.
‫I believe this is sufficient for us right now at least
‫about numbers because we have so many data types
‫and we are going to do a lot of examples with numbers later
‫on as well.
‫So let me talk about strings.
‫We have briefly talked about that before
‫right? We have talked about that
‫this is a text.
‫So let me do an example.
‫Just write String with an upper case S
‫and give some name afterwards.
‫Like this is an object name like, "name",
‫or, "myString", or "myName", or anything you want.
‫Okay let's go with name
‫for example and open this quotation marks
‫and between the quotation marks, write your text.
‫So you can do it with your own name.
‫I'm gonna do it with James Hatfield.
‫So I'm going to call this name, I'm going to
‫create another string, which is surname, which is Hatfield.
‫Okay? And don't forget with semi-colons at the end
‫and now I'm going to print name
‫and now I'm going to print surname.
‫Just beware that I'm not putting
‫any double quotations, quotation marks
‫in the System.out.println over here.
‫I'm just writing surname or name
‫because I can refer to that variable right now.
‫So this is good.
‫So if I run this, of course it will print
‫out James Hatfield one by one over here.
‫So now I have these variables
‫I can do whatever I want to do with them.
‫For example, I can create a new string out of those.
‫Like I can just create a full name
‫and some name and surname together like this.
‫So what happens when I add one string to another?
‫So let me try to print line
‫that as well so that we can see the results in the logs.
‫Here you go.
‫As you can see, it added them side by side.
‫So we can see the name and surname together like this.
‫So of course you're thinking about how to put a space
‫between name and surname right now it's very easy.
‫You can do like this.
‫So, name plus a space over here and plus surname.
‫So if I run this, then I will see, "James Hatfield".
‫Now I can use those variables in wherever I want
‫at this point on, right?
‫So this is strings, this is very basic.
‫This is just a text.
‫So before we have learned about numbers, they were integers
‫and floats and doubles and longs.
‫Now we have learned about strings.
‫Now we wanna move on to booleans.
‫So this is a type as well.
‫So what kind of a data type is this?
‫So boolean is a true or is a false.
‫So they have only two values
‫actually it's either true or false.
‫So how do we use them?
‫So let's create a boolean
‫and create it like this boolean with small b.
‫And then you can give it a name.
‫For example, in a real life example would be a game
‫like for tracking if character is alive.
‫So if it's true, then my character is alive
‫and if it's false, then my character is dead.
‫So maybe I can keep track
‫whether my character is alive or not with a variable.
‫I can change it anytime I want.
‫Like this:
‫Let's print those out and let's see
‫if we can see the false over here.
‫Here we go.
‫As you can see, it's the most basic data type of all.
‫So it's either true or false.
‫There isn't many thing to talk about it right now
‫but later on we are going to see a lot
‫of usages of booleans as well.
‫So once I create a string
‫or once I create a variable, I can change it, right?
‫For example, I have changed name to be Lars
‫and now if I print name, I will see Lars as you can see.
‫But I cannot do that.
‫I cannot change name to be 40 like this,
‫because I have defined name as a string, not an integer.
‫As you can see it gives me an error.
‫I'm expecting a string and you are giving me an integer
‫it says. So whatever you have specified first
‫you have to do that later on as well.
‫So let me comment this out and go up and over here.
‫For example, we have double z.
‫Now can I do that?
‫Can I say this is a four?
‫Yep, I can do that actually.
‫It doesn't mean it's necessarily an
‫integer right now because it's perceived as a double.
‫But if I do that
‫as you can see right now, it's giving me an error.
‫It's not exactly a double.
‫It's a string it says.
‫Whenever you do 4 it, it just thinks it as 4.0.
‫Okay? So it's okay
‫but turning it into a string, it's not okay.
‫So that's it for the most basic ones.
‫These are the data types that you're going to
‫need when you try to learn the other concepts
‫of Java in the following lectures.
‫So make sure you follow along with the next lectures
‫in order to comprehend all of those things in a better way.