 Hey everybody, it's Brian. Today we're going to be discussing logical operators. What are logical operators? Well, let's just jump right in and I will show you The ampersand equals an and The pipe character equals an or And let's see here the exclamation equals not There is another one It is the carrot Equals X or or exclusive or now what are these deal? Let's cover the and first and Z easy to understand. We'll say index equals zero. I hope if I could spell it And into why equal one you say if X equals zero and Why equal one and you can guess what's going on with this code is I'm feverishly typing You're saying both X and Y have to equal a certain value So we're saying if X equals zero and Y equal one then System print line. Yes Save our work run it. Yes. So if we change Y to two Will this run we're executing this entire block here remember we're saying if X equals zero and Y equal one when you see Y does not equal one. So Nothing happens We could put an else in here and that way we can see exactly what's going on. Oh Errors exist what errors do I have here? Oh I see what's going on have an extra one in there. You can see no So that is the and statement Now the or statement is We're saying either one of those can be true X equals zero or Y equal one I'm just gonna tick always save there we go. So yes Why is this saying yes because X is zero it says X equals zero so it doesn't even go any further It says we've already satisfied that expression Now the not operator is very simple. Let's just do If X and we'll say not equal five if X not equal five then Print yes, otherwise print. No, you can see X is zero. So guess which one it's going to do And it says yes, so what you're really saying is Not equal remember the two equal signs mean equal Exclamation equal means not equal and One thing you should remember that is if you just do X equals you're actually assigning the value to X You're not actually checking the expression There's no X is not equal five if we switch this to not equal Then yes, so that's how the not operator works now the X or X or is a little confusing to me It's all about bit shifting. I'm not really going to cover it because I'd a don't fully understand it and Be I hardly ever see it used out in the real world. So Really, I'll try to cover the syntax, but bear with me here We'll just simply say system out print line And we will say X X or Y Whoops. Hope if I actually put that in the brackets So we're just going to print out X Exclusive or to Y See what it says it says to now. Why does it say to well? I don't really have a diagram like my beautiful Sun certified Java programmer book does but an exclusive or basically looks at it in terms of binary representations a bunch of zeros and ones and It says it'll take one over the other For example, let's just flip this and we'll say why exclusive or X And it still says to so no matter how you represent that it's still going to do the same thing Because it's an exclusive or it's looking at it in the the bit level You see we have two different statements here Why exclusive or to X X exclusive or to Y now when we run this you should get the same results two and two That's an exclusive or it's kind of a holdover from the old C++ days I know I'm probably gonna get hate mail for saying that because there are people out there that do use the Exclusive or X or as it's called. There's actually encryption with X or which I wouldn't recommend Anyways, that's all we got time for today. I thank you for watching and I hope you found this video educational and entertaining