Welcome back.
In this video we're going to look at relational operators okay.
Therefore I'm going to make myself some space here.
And basically the idea is that I compare two values.
And then I make a decision whether it's true or false.
So let's say I have int num one which is going to be five and int num two which is going to be six.
And now I compare those two.
So I'm going to have a value which is going to be a boolean which I'm going to say is higher.
Then I'm just going to use num one greater num two.
And that's it.
So this here is a relational operator this one here.
So there are other relational operators.
So let's look at them.
There is this one here.
Then there is this one.
And finally this one okay.
So maybe we bring them into the right order like so okay.
So these are the different relational operators that there are.
So this one is less than less than equal greater than and greater than equal.
Therefore let's debug our app by adding a breakpoint here.
And then running it.
So we will see is higher by default is set to false.
That's the default value of booleans in general.
So whenever you are creating a boolean by default it will be set to false.
Only after you initialize it with a different value it will be overwritten.
So now if we go to the next step by clicking Step Over and now we hover over it, it's still false.
Okay.
Let me show you that this is still the, uh, still the case.
If I do it the other way around, that it will still be false at start.
So you see here as a default value, a bool is false.
It says is higher is false.
Even though now I'm setting number two being higher as number one.
So that's the request.
And we know that number two is in fact higher than number one because six is higher than five.
So if I now go into the next step you will see that is higher suddenly is set to true.
So that means during initialization a boolean is by default false until you actually override it with
your own value.
So now is higher is set to true okay.
So this is something I wanted to make sure that you understand.
And now we can go ahead and understand what's going on.
Therefore I'm reverting it back to this way.
So here I'm saying is the left hand side greater than the right hand side.
So maybe we should call it is greater.
Maybe that's better.
So left is greater than right.
If that is true then this statement here will be true.
So we're saying if num one is greater than num two then is greater.
The boolean will be true.
Otherwise it will be false.
So now how can we use that.
We can use that for an if statement where I'm saying if h and therefore I'm going to create a new integer
here.
So I'm going to say int h is let's say 35.
That's my age.
If h greater than 18 then I'm going to say go party.
So here go party, go party in the club.
Because at least in Germany when you're 18, you can go into the club and you can start drinking and
all of that good stuff.
So here, let's run this again and we can see go party in the club.
That's because my age is above 18.
But now let's say my daughter, she's seven.
Would she get into the club.
And let me actually make sure that I make this statement well commented out.
So now let's run it again.
And it just says a okay.
That's because my daughter is not above 18.
So her age is not greater than 18.
Now the problem here is if we look at this particular example, then we will see that somebody who is
18 will actually not get into the club, but only people who are older than 18.
So how can I make sure that 18 is included as well?
Therefore I can use the equal sign.
So here I'm saying is greater or equal 18.
So if the age now is going to be 18 then it will be included.
Otherwise in our case before it would not be included.
So let me show you the actual number here.
Let's set that to 18.
Let's run it again and we will see.
It says a okay so we're not getting into the club, but if I now say greater equal then I suddenly do
get into the club okay.
And it says go party in the club.
So I think now is a good.
Time to look at else.
So let's do that in the next video.