Hi everyone in this theater early on I'm going to touch about logical operators.
OK.
So first we need to create a Java project.
So just click on this file new.
And then click on Java project.
OK.
So for the project name just type in here.
Logical operators
OK.
And click on finish.
So as you can see here our project is now created.
So first we need a class for our project to just click on this as our See folder and then click on Phi
new and then click on class.
So for the class name just type in here logical operator
Okay for the package name we need a reverse domain here.
Just type in your column that your name dot project name ok.
Logical operators are OK for the modifiers to publish and make sure that you check the check box here
that says public static void main method.
OK.
And then click can finish.
So as you can see here our project is now created.
So first let me actually delete this comment here.
And in order to make this a little area of there you just need to actually double click on this logical
operator that job I have.
OK.
And here we can actually write our codes inside the main method.
I'll talk more about the methods later in this course but for now I make sure that you write your code
inside the curly braces of this main method.
OK.
So logical operators
so expressions that result in boolean values such as comparison operators can be combined to form more
complex expressions.
OK this is handled through logical operators which are used for the logical combinations.
OK so the first one is and.
OK.
Or the next one is Zaur and not.
OK so now let me actually show you some real examples in order to make this concept more clear for you.
OK so now you want to create a variable here.
Ain't salary.
OK.
And then I assign a value to my variable.
For example 2000 and I need to put a semicolon at the end of my variable here.
OK.
Now I want to create another variable here.
OK.
So the data type of my variable is boolean.
OK.
And the name of my variable is R for example is higher.
OK.
And then I want to assign a value to my variable here.
OK so now I want to combine expressions together and then assign that value to my higher level here.
OK so now I want to actually combine expressions together and then assign the value of those expressions
to my highest value.
OK so let's see how we can do that.
OK.
So first finish putting in parentheses.
So now I want to actually referred to the name of my salary variable here.
In order to read it's value.
OK.
So I just type in here salary.
OK.
So now I just put in a comparison operator here as you can see a greater than sign.
OK.
And then I put in a value here for example a thousand.
So now I need to put in a semi-colon at the end of my statement.
Ok here I am telling the computer if the value of this salary variable is greater than 1000 the value
of the expression evaluates to TRUE.
OK.
But if the value of this salary variable is less than or equal to one 1000 the value of this expression
as you can see here the value of this expression evaluates to false.
OK.
So let's actually output the value of these variables for the console and let's see what's going on
here.
System that out that princeling.
And then inside the practices I just referred to the name of one variable in order to read its value.
OK.
And then at the end of my statement I need to put in a semi-colon OK.
Again I want to output the value of this is higher variable to the console akey the value of this boolean
variable that I created in line 17.
Okay.
So I just need to type in here system that out that line and then inside Apprentice's I just need to
refer to the name of my variable and that at the end of my statement I need to put in a semicolon OK.
So now if I run my project as you can see it's going to output these values to the consulate.
So as you can see here the first one is disvalue.
Here is the result of execution of this line of code here.
OK.
In line 15.
So this value is the value of my salary variable that I created in line 14 and I decided to output the
value of this variable to the console in line 50.
OK.
So orders does matter here.
OK this is very important and in inline 17 as you can see here.
I created another variable here with the boolean data type.
OK.
And this is the name of my variable is hired and I assigned a value to my variable here.
OK.
I created an expression here and I specified that salary must be greater than 1000.
OK.
If the salary is greater than 1000 the value of this expression evaluates to true and that true value
will be assigned to my highest value.
Well if the value of the side of the variable is less than or equal to one thousandth the value of this
for expression evaluates to false and that false value will be assigned to my it is higher value.
So in line 18 I decided to output the value of this is higher is the variable to the console.
So as you can see here the value that I assigned to my salary evaluable is 2000.
OK.
And in this expression I specified that the value of the salary variable must be greater than 1000 in
order to evaluate its expression true true.
OK.
So let's actually see what's in the console.
As you can see the true value is now out to the console.
So the value of this expression is evaluated to true because the value of the solidly value bet as you
can see 2000 is greater than 1000.
OK this expression evaluates to true.
And that true value will be assigned to might is higher variable and in line 18 I decided to output
the value of this is variable to the console.
As you can see here.
Okay.
So now I want to actually combine two expressions together.
Okay.
So first let me actually comment out these lines of code here.
Okay.
And here I want to actually create another variable in for example the name of my variable with the
money.
Okay.
And I want to assign a value to my variable for example 100.
Okay.
And then at the end of my statement I need to put in a semi-colon.
Okay.
So here I want to output the value of this valuable to the concert to make sure that it works.
System that out that princeling.
And then inside Apprentice's I just need to refer to the name of my variable.
So let me actually put a text here in order to make this value more readable.
This is the value of the money roudy of it.
OK.
And here after the double codes I need to put an A-plus operator here.
OK.
Because I want to concatenate this text here with my variable name.
OK.
So I just need to type in here money and at the end of my statement I need to put in a semi-colon OK.
So if I run my project now as you can see there is no space between this valuable vote here and the
value of my value.
And so here I need to actually create a space here after the variable vort and if I run my project again
this space is now created here.
So this is the value of the money variable 100 as you can see.
OK.
Now let me actually create another variable.
So the data type of My value is boolean.
OK.
And now you want to actually give a name to my variable for example.
Chan by car.
OK.
And then you want to assign a value to my value.
For example false.
And then at the end of my statement I need to put in a semicolon OK.
So now I want to output the value of this invaluable to the consulate system that out that print line
and then inside the apprentice's I just need to refer to the name of my variable.
Can by car.
OK.
And then at the end of my statement I need to put in a semicolon.
OK.
Inside it up and codes just type in here.
This is the value of the can by card value.