‫We'll come back in this video.
‫We'll learn about the operators in Java.
‫Operators are special tools that allow us to perform various tasks for example, mathematical equations,
‫mathematical calculations, logic operations, and so on.
‫Let's start with the first type of operators, which is the arithmetic.
‫Arithmetic operators help us do math in our programs.
‫They work with numbers.
‫So what are the arithmetic operators that we use in the school?
‫The plus sign, the minus sign the multiplication, which is the asterisk and the division.
‫And there is a new operator that we're going to introduce in this video, which is the modulus.
‫Let's start with the addition.
‫It's like adding two numbers together.
‫So for example, system dot out dot print, and I'm adding one plus two.
‫Let me run the program.
‫You can see we have.
‫Three as a result.
‫Now let's try to multiply.
‫Run again.
‫And you can see number two is the result.
‫Now let's introduce the modulus.
‫It's like finding the leftover after sharing things equally.
‫So, for example, if I have ten here and I am divided it by five.
‫That division will result in two.
‫Look, please pay attention with me now.
‫The division, the normal division it will result in to ten over five is to.
‫But the remainder There is no remainder because if two times five will result in ten.
‫So there is no remainder.
‫Let me try this modulo or modulus.
‫Operator.
‫Let me run here and we can see that the zero is the result.
‫There is no remainder, so this modulus will give us the remainder ten modulus five is equal to zero.
‫Ten over five or divided by five will be two.
‫So this is the remainder.
‫The leftover of the division.
‫And the division operator.
‫Okay.
‫Let's move to another type of operators, which is the comparison operators.
‫These operators help us compare things to see if they are true or false.
‫We have equal to.
‫It's like asking if two things are the same.
‫We have an integer x equal to ten.
‫I am printing out the value or the result of this comparison.
‫I am comparing the variable x the value of variable x if it is equal to nine, nine does not equal ten,
‫so the result will be false.
‫Let me run and see.
‫And here we go.
‫It's false.
‫Now let's try to make it ten.
‫Let me run again.
‫And we have here.
‫True.
‫So here we're going to compare X with the value ten.
‫If it is equal, it will return.
‫True.
‫Now let's move to the next comparison operator, which is the not equal to.
‫It's like asking if two things are different.
‫I am trying to check if X is different from ten.
‫No, x is different from ten.
‫No x equal to ten.
‫So it will give me.
‫False.
‫Okay, You can see it.
‫Now let's see if x different from 9999.
‫Run.
‫And you can see it's true.
‫Okay.
‫This is the second comparison, operator.
‫The greater than.
‫It's like checking if one thing is bigger than other.
‫The less than is checking for one thing is smaller than the other.
‫So I'm checking if x is greater than 100.
‫Let me check.
‫And.
‫It's returning false.
‫So X is not greater than 100.
‫Greater than.
‫Or equal.
‫And less than.
‫Or equal.
‫Check if one thing is bigger or smaller or equal to the other respectively.
‫Let me check if x greater than or equal to ten.
‫Run and here we get through because it's equal to ten.
‫Greater than or equal.
‫It's equal to ten.
‫So this is how we use the comparison operators.
‫There is another type of operators in Java called logical operators.
‫These operators help us combine conditions and make more complex decisions.
‫We have three logical operators and sine or sine or not sine operator.
‫The end sign.
‫It's like checking if two things are true at the same time.
‫Let me give you an example.
‫We have a boolean here is sunny equal to true.
‫It's sunny today and boolean has umbrella or need umbrella.
‫Equal to false.
‫If we combine these two booleans, these two conditions, conditions in one boolean should go outside.
‫Boolean equal to is sunny and.
‫Not umbrella and don't need an umbrella so we can go outside.
‫This is always true because we have.
‫Have we have this false.
‫Not false is equal to true.
‫So this condition is true.
‫Is sunny is true.
‫So true.
‫And the true will return.
‫True.
‫So we can go outside.
‫If it is not sunny or we need an umbrella.
‫We can't go outside.
‫Let me create another boolean.
‫Can play games.
‫Equal is sunny or need umbrella.
‫In this example should go outside is related to the weather and the umbrella need.
‫So if it is true it's sunny and we don't need umbrella.
‫So these two conditions must be true to be true.
‫Here can play games.
‫Either it's sunny or we need an umbrella.
‫Either it's sunny or it's rainy.
‫It's not the big difference because we can play games on PlayStation or in computer inside the house.