Welcome back in this video, we're going to look at other data types such as billions.
So for example.
Bullying is a type which represents logical values, so it can have two possible values, true and false.
So we have this variable called is sunny and I'm going to make it to bullying.
And now I'm going to assign truth to it.
Let's say a little later, the sun is not shining anymore.
Then I can just say it's sunny.
There's going to be false.
So I reassigned a new value to it, so I assign faults to it now.
So sunny or is sunny will now be false.
Of course, I don't need to assign the bullion to it, or I don't need to explicitly state that I want
to use it as a bullion because once I assign a bullion value such as true to it, it will know that
his son is going to be a bullion type.
Then there is a another type which is called character or char.
So you can assign a char by using the post office so you can see the value letter.
Char is just an A, and I make this a char by assigning a value or a letter in this case, which is
surrounded by apostrophes.
So if we look at letter char, we can see it's of type char, which is character that it did.
The char is also of Typekit char.
It's really not that much of a difference.
It doesn't matter if it's an a a one or even a dollar sign.
But as you can see, it cannot contain more than one sign.
That's the limitation of char.
So a string is basically a connection of multiple chars.
It's just multiple chars together.
In this case, it's five chars which come together to becoming a string.
Now that we talk about string, let's have a look at strings a little more.
So let's assume we have this string variable, which is called my string or my SDR, and it has to text
Helloworld.
Now, if I want to access a certain character from that string, what I can do is I can use the following
approach.
So I'm going to call this one first char in string, and this will be my string.
That's the position zero y zero.
Well, because Scotland is a language which starts calculating or counting at zero.
There are other programming languages which start counting at one such as hour, but most programming
languages start counting at zero.
So zero is the first letter.
So if we print just now, let's say we want to print this first chart in a string.
So let's just do that first character.
And we run this code.
So let me.
Run it again.
And we see first char or first character is H.
All right.
So in Helloworld, the first character was, in fact, H.
If you want to get the last character, what you can do is the following.
So I'm just going to paste it in here.
Last character and string will be again my strength, and then in square brackets, I use my strength
at length.
With this, I get the length of the whole strength.
And then I say minus one, which just says, OK, give me the last one, because if the length is in
this case.
11.
So five characters here, then one, which is this empty space.
And then another five characters become two 11 characters.
So 11 minus one is going to be 10.
So we're going to get the 11th position, which is going to be the deep.
So now let's just print out the last character.
And we can see this last character as which is, in fact, Helloworld with the D.
All right.
So some meaning it up.
There are multiple different types that we can use when we create variables.
Variables are immutable if we use the vol keyword and there are mutable, so changeable.
If we use the VAR keyword, then we don't have to specifically state what kind of data type we want
to use.
If we assign the right value to it, if we assign a value which is of a specific type, such as a number,
which is a whole number, it will automatically assume that we want to have an integer.
So if we want to have a byte or short, for example, then we would need to explicitly state that by.
Creating the variable with that type and with long numbers, we can use an underscore in order to make
it more readable.
This is a new feature that is super useful.
We can use that for string, for integers as well.
By the way, this makes them more readable, and the same concept goes for doubles as well, where the
assumes that we want to assign a double if it's a floating point number.
But if we want to specifically use a float and we have to state that by adding an F to the number itself.
Then there is the Thai bullion, which is used to only have two states, so either something is true
or something is false, which is a super useful, and we will use that quite a bit.
And we have characters which we can use in order to just one use one character, which doesn't have
to be a character, but it can also be a number or a symbol.
Then we have strings, which is a collection of a bunch of characters which we can use for text.
And if we want to print something out, we can use this print statement, which then prints it onto
our console, which is just a little area here at the bottom, which helps us to test stuff and test
if a certain variable has a certain value.
Of course, there are other ways to do so, but the print statement is a very convenient one.
And another one important aspect, and I told you multiple times, but I really want to state that again,
you don't have to specifically state your data type because of type inference, and maybe I'm going
to add this word here type interference, which just means that.
Finds out the tape from context, which is super powerful and useful and makes our life a lot easier
in most cases.
So let's say see you in the next one.