And this lecture, I'm going to talk about operators, so why we need operators, because we need to
change the value of the variables somehow and the signs or operators help us to do the job.
Some of them are well known from math and others might be new for you.
There are operators that are connected to numbers.
Others are helping in comparison.
So what operators are by definition, they are used to perform operations on variables and values.
I think it will be more clear if I introduce them.
This lecture is divided into six parts.
The first one will be assignment operators.
Second, we will look into arithmetic operators, then on the operators.
After that, equality and relational operators.
The next problem will be the ternary operator and last the two logical operators.
After we will finish with these, there will be a coding lecture to that started.
So you have been the first assigned operator, the equal sign.
Nothing special here.
Here are many other assignment operators, but to understand them, we must go through other operators
first.
We will get back here at the end of the lecture.
So moving on to arithmetic operators, the first one, the plus sign for addition.
It's also used for strengths.
Subtraction is also a simple one.
Multiplication not too complicated either.
OK, the next one is a bit trickier.
Division divides the number and returns the whole part.
We will look into this in the coding part.
Moving on to the next operator.
The reminder.
So in case of price variable, we divide five with free and what remained is two.
So that what reminder operator returns for us.
We will cover all of these with examples.
These operators are commonly used, but there is nothing unusual here.
Moving on to unary operators.
Honourary operators have the name unary because they are not connected to another value or variable.
They can be used for one variable we can use plus sign phone numbers, but it won't make a negative
value to positive.
But minus sign will do double plus sign increases the value by one and double minus will decrease it
by one.
Both can be used before and after the variable or value.
And the last one in this group is the exclamation mark or invert.
It can be used for booleans to change the true to false and false to true in the case of the example
here is damaged will have a false value.
The next group is used to compare variables and values stored in those variables, the result of the
comparison will be a boolean.
So first double equals use to compare to values.
Five equals five will return to.
The second one is not equals.
So five not equals five.
So it will return false because five equals to five third and fourth greater than and less certain.
I think I don't have to tell you how they operate.
The next two are greater than or equals and less than or equals.
These are also well known from math.
The last one here is a bonus and it is used for data type check.
You can check whether a variable data type is string or any other object.
We will get back to this later.
Ternary Operator Group is a one operator group.
It is used in control flows to run different code based on expression values.
So variable name equals expression, questionmark expression one, common expression two and a semicolon.
So if the expression is true expression, one will be assigned to the variable.
If expression is false expression two will be assigned in case of a car damaged text while you will
be this car is damaged if the is damaged is true.
But if it's damaged is false.
Damaged text will be this car isn't damaged.
Let's move on to the next one, so logical operators have two elements, the first one is or operator,
two vertical lines if we have to boolean expressions and at least one of them is true, the other operator
will return it through the other operator.
And this group is and operator, it will be true if both boolean expressions are true, so false and
true, we will return a false.
On the other hand, true and true would return true.
I think it will be much easier to understand in the coding part.
So moving back to assignment operators now, you have introduced to other operators that will be needed
for this part.
We will use enterprise equals five as a base for all the examples first from the new ones ad and equals
it takes the price variable, adds five to it and assigns 10 to price variable.
This operator can replace the following.
It makes it easier because you don't have to type in price two times.
Next is subtract and equals.
It takes price with value five and subtract five and assigns zero to price variable based on the one.
Before this it can replace the following.
So price equals price minus five, then multiply and equals five is multiplied by three and price will
be fifteen in that case and it can replace the following.
Divide and equals does the same way, and at the end, the value of price will be won and the line it
can replace also on the right and the last one as a reminder and equals the value of price will be to.
One last group I didn't even mention at the beginning is bitwise and big shift operators, and there
is a good reason why I didn't mention them.
These are not commonly used.
Maybe I can say never the reason why I still mention them, because the way they wrote is close to other
operators.
And if you miss, for example, a vertical line from your operator, you will get bitwise or which won't
give you the same result at all.
If you miss an unsigned from double and operator, you will get bitwise and then right shift and left
shift that are close to greater than and less certain and unassigned right shift.
The last two are bitwise complement and bitwise X or as I said, you don't have to know these.
Just keep in mind that Java has such things as well.
So that's it.
Let's move on to the coding part.