Relational or Comparison Operators - Java programming tutorial for beginners
Coding River
Relational or Comparison Operators & logical expressions - Java programming tutorial for beginners
In this video we are going to talk about Relational Operators By definition, a relational operator is an operator that allows you to make comparisons in a program Relational operators are used in logical expressions And a logical or boolean expression is any expression that evaluates to either true or false
Let’s take an example to explain further Suppose we have two integer variables int a = 10; int b = 28;
And we want to compare these two variables To do that we will use a logical expression and that expression will contain a relational operator Since a logical expression evaluates to a boolean value Let us declare a boolean variable first
Now, let‘s write the logical expressions in which we will compare the two variables c = (a==b); c = (a!=b); etc.
So here are the logical expressions And, as you can notice in Java there exist 6 relational operators that allows you to make comparisons the equal to operator the not equal to operator the less than or equal to operator the less than operator the greater than or equal to operator the greater than operator
As I said, each of these expressions will compare the values in variables a and b before returning a boolean value that is either true or false
What we can note here is that each relational operators is a binary operator, that means that it requires two operands
Relational operators can be used with all primitive Data types which are short, long, double, float, integer and char as well
For char values, whether an expression evaluates to true or false depends on the Unicode value as a decimal integer of the characters in the character set
For example we can write char d = ‘A’; char e = ‘B’;
Then c = (d == e);
So guys, that’s it concerning Relational Operators In the next video, we will talk about Logical Operators
Thanks for viewing, I hope this video was informative and please do not forget to like and SUBSCRIBE to this channel for more. Thanks !!!!!
#codingriver #java #programming ... https://www.youtube.com/watch?v=hKptCw55VqU
11253174 Bytes