Welcome back.
And this video, we are going to check out the assignment operators and the increment or decrement operators
because we're going to use them quite a bit.
So assignment operators are the ones you can see here, and we have already seen them to a certain degree
where we just had a variable.
And I'm just going to call this one.
My name is going to be five and then I can go ahead and say my name plus equal three.
So what that will do is it will add three to my mum value.
So it's going to be the same thing as if I wrote My name equals my num plus three.
All right.
So these two are interchangeable.
And as you can see, it even prefers the other one.
So it even prefers the operator assignment, as we have seen here.
All right, so.
Assignment operator is this plus equal three or this minus equal or multiplied equal and so forth?
So I can, of course, go ahead and print this print and it's going to be my name is Taylor my name,
and I'm going to comment on all our other print line statements from earlier videos.
And let's run this again.
And as we see says, my name is eight.
All right, so that is an assignment operator.
Now please go ahead and multiply that with four, so multiply my number with four and stored it in my
name, but use an assignment operator for this.
All right, I hope you tried it, so it's my numb multiplication or asterisk equal four.
And now let's print this again.
In the next line.
And we can see it's 32.
All right, so these are the assignment operators.
Now let's look at the increment and decrement operators because they are something that is used quite
often as well, and they are just a double plus or double minus sign.
So we can just go ahead and do the following my num plus plus nothing more than that.
So let's print my name again.
And this is going to be here, actually, let's print it here, and let's print it after the incrementing.
So this plus plus is incrementing, which means increasing the value by one and then minus minus decremental,
which means decreasing the value by one or reducing one.
So once we run this, we can see my name is 32 and my name is 33, so my name is 32 here at this line
and 33 and this line.
So that's what this increment does.
Now let's do a decrement.
And at that same time, I want to show you something that is super interesting and that is to use to
increment after use, which means we use increment after my name.
And then again, we can use it before.
So in this case, you can see we cannot just use this approach, we have to use the brackets, so I'm
going to use curly brackets here as well because this is an expression that I want to execute before
actually printing it on the screen.
So let me show you how this will impact our application here.
So let's run this again.
All right, so there we are.
So we had minus 33.
That's this line here, right?
So we increased my name of being 32, which was at this point.
And then we increased it by one here.
Then we go ahead and print that number and then we say, OK, let's increase the value by one.
But for some reason, it didn't increase the value.
Why is that?
Well, that is because this plus plus will only be executed once this line of code is finished, so
pretty much at the beginning of the next line.
So in line 75, my name is still 33.
Then it's increased by one.
So in line 76 at the beginning of the line, it's going to be 34.
And then would you?
Plus plus minus, which means we increment just before we execute or we use this variable, which means
that now it was 34 at this point, +1, which means now it's 35.
And that's exactly what is printed onto the console.
So now you can see that my name is 35.
So that's the difference between using the plus plus or the increment or decrement operators before
or after, because it really has an impact on when they are executed.
And now you know the difference, but very commonly it's used afterwards.
So you increment after words because usually you don't use it in line as we do it here.
So now please add another print line statement just underneath it.
So in line 77, in my case, just underneath this statement and there decreased the value so that it
will show my name is 34 as the next print line statement.
All right.
So I hope you tried it.
So what I need here, of course, is to use minus minus before my name and not after one.
So I'm going to decrement the mine unbearable just before it is going to be displayed and printed onto
the console.
So just before it will be used, so to say.
So there we are.
It says my name is 34.
All right, so that's assignment operators and the increment and decrement operators.
And in the next video, we are going to see how we can finally use some of those operations usefully
because so far we had some examples of what we can do with it.
But now let's see what we actually can do with it and get something from it, because so far that's
been rather fundamental or rather basic.
So see you in the next video where we're going to check out if statements.