Signal Of Forex

Using the logical operators

Posted by Tricking Saturday, November 22, 2008

Using the logical operators in Java 
by Joe Keny

The logical operators to introduce the concept of Boolean algebra to the Java language. They are a fundamental part of the language and can make conditional code cleaner and more concise. Programmers often use the logical operators in connection with the statements to evaluate, whether true or false .

Use the operator AND 

Use the AND operator (whose symbol is & &). In Java, & & evaluates to true if and only if its two operands (objects manipulated) to assess the true .

understand that their operands can be any expression that evaluates to a Boolean value. This includes any comparison operator (such as greater than>, less than <== or equal to), any method that returns a Boolean or boolean variable itself. "" Int a = 7; int b = 10; if (a> 4 & & b <20) (/ / This will be true, since both operands to the & & operator to assess the true) "" 

Use the OR and NOT 

Use the OR operator (whose symbol is | |). | | Evaluates to true if one or both of its operands evaluate to true. Operands can be any expression that evaluates to a boolean. "" Int a = 10; int b = 40; if (a == 7 | | b> a) (/ / This will be true. Despite the first operand evaluates to false, / / the second will be assessed a true .}""

Consider using the exclusive OR operator (or XOR, whose symbol is ^). evaluates to true if you are good, but not so much of their operand evaluates to true. In this case, the XOR operator is used as a Boolean logic. "Int a = 7; int b = 10; if (b> a ^ b == 10) (/ / This will evaluate to false because both operands are true }""

Reverse the result of a Boolean expression in Java using the logical NOT NO (whose symbol is!). If your operation is certainly not the expression will evaluate to false .

Use the NOT operator with parentheses and other expression since Boolean operator does not bind very closely (operator of your choice is very high). The exception is if it is paired with a single boolean variable. This example demonstrates the use of Boolean NOT "." Int a = 7; int b = 10; if (! (A == b)) (/ / This is to assess from a certain b == be false, and the operator does not invest }""

0 comments


ShoutMix chat widget