Java Programming ICourse Home Java Programming IICourse Home Start Here
JoC Help
Bonus VideosQuiz Reviews
Java Tutorial Trail: Learning the Java LanguageCodingBat WarmupsLogicStringsArraysAP Computer ScienceHow do I...
Related Links 
If StatementsJoy of Code #5: If statementsNothing to download  we continue with the scenario from last time. Joy of Code #6: Random behaviorIf you have previous experience with boolean expressions, you might want to skip directly to the quiz. If statements: IntroductionIf statements: Java statementsIf statements: ConditionsJava OperatorsComparison OperatorsBoolean expressions can be written using comparison operators. Comparison operators are operators that compare two values. Java has a number of these:
For example,
is true, and
is false. Methods with

p  q  p * q  p + q 

0  0  0  0 
0  1  0  1 
1  0  0  1 
1  1  1  2 
p  q  p && q  p  q 

false  false  false  false 
false  true  false  true 
true  false  false  true 
true  true  true  true 
There's also a unary operator !
that produces the opposite of a given boolean value.
In other words, !true
is false
and
!false
is true.
Logic Problems on CodingBat
You can find further discussion on the
After watching the video and reading text of
Next, work on
This web page was created to supplement a course offered by The Center for Talent Development.  This work is licensed under a Creative Commons Attribution 3.0 Unported License.  Terms of Use. Privacy Policy. 