IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesJava  Print This     

Logical Operators (Java and Delphi Cross Reference Guide)

By Mike Prestwood

Java versus Delphi: A side by side comparison between Java and Delphi.

 
Operators
 

A language symbol used for assignment, comparison, computational, or as a logical.

Logical Operators

[Other Languages] 

Languages Focus

Logical operators perform conditional and, or, and not operations. Some languages support both binary logical operators that link two and unary logical operators negate (make opposite) the truth value of its argument. Finally, some languages short circuit logic. For example, with this or that, if this is an expression returning true, then that is never executed.

Java: 

Java logical operators:

&& and, as in this and that
|| or, as in this or that
! Not, as in Not This
& boolean logical OR (not short circuited)
| boolean logical OR (not short circuited)
?: Ternary (short for if-then-else)
~ Unary bitwise complement
<< Signed left shift
>> Signed right shift
>>> Unsigned right shift
^ Bitwise exclusiv OR

Syntax Example:
//Given expressions a, b, c, and d:
if !((a && b) && (c || d)) {
  //Do something.
}
Delphi: 

Delphi logical operators:

and and, as in this and that
or or, as in this or that
not Not, as in Not This
xor either or, as in this or that but not both

The Delphi compiler default is to short circuit multi argument boolean expressions when the result is known before the evaluation completes. To disable short circuiting, use the {$B+} compiler directive. To reset it back to the compiler default of short circuting, use the {$B-} compiler directive.

Syntax Example:
//Given expressions a, b, c, and d:
if Not (a and b) and (c or d) then
  //Do something.












Sales Website: www.prestwood.com Or visit our legacy sales site: 
legacy.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]