December 1999
Intermediate to advanced
816 pages
20h 27m
English
There are several kinds of operators in Java, including relational, bitwise, and arithmetic.
The two logical operators in Java are
AND: &&
OR: ||
These are primarily used in if and while tests. For example, you might have
if(x > 5 && y < 12) // if both conditions are true,
// do the following
System.out.println("x qualifies");
else // They are not both true
if(a ==3 || b < 7) // if one or both of these
// conditions is true do the
// following code
System.out.println("a might qualify");
The AND condition says that both Boolean tests must resolve to true for the overall test to be true. Remember that an if test must resolve to a Boolean condition of true or false. The OR test says that either the ...
Read now
Unlock full access