Download presentation
Presentation is loading. Please wait.
Published byAnnis Bishop Modified over 9 years ago
1
1 Chapter 3: Loops and Logic
2
2 Control Statements If statement Example NumberCheck.java Relational operators (, >=, ==, !=) Using code blocks with If The else statement Nested If Example: LetterCheck.java
3
3 &&, &, ||, |, ! They are working upon logical expressions to produce true/false What is the difference between &&, & (short cutting) The standard Library character manipulation classes (Character.isUpperCase(), etc.) Logical Operators
4
4 It has the following form and always returns a value of one of the two exps. Logical exp? exp1:exp2; Example: ConditionalOp.java The switch statement can perform multiple selections. Using the break statement Local variables are visible only in limited scope Example: Scope.java Conditional Operator and switch
5
5 Different types (for, while, do—while) Initialization, test, & increment conditions Loop counters can be int or float Nested loops, example Factorial.java Break, continue, labeled break and continue Assertion: “assert logical-exp;” Compile with “-source 1.4” and run with “-ea”, example TryAssertions.java Loops
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.