Chapter 3: Loops and Logic - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Chapter 3: Loops and Logic

Description:

... form and always returns a value of one of the two exps. Logical exp? ... Compile with '-source 1.4' and run with '-ea', example TryAssertions.java. Loops ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 6
Provided by: far71
Category:
Tags: chapter | compile | logic | loops

less

Transcript and Presenter's Notes

Title: Chapter 3: Loops and Logic


1
Chapter 3 Loops and Logic
2
Control Statements
  • If statement
  • Example NumberCheck.java
  • Relational operators (lt, lt, gt, gt, , !)
  • Using code blocks with If
  • The else statement
  • Nested If
  • Example LetterCheck.java

3
Logical Operators
  • , , , , !
  • 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.)

4
Conditional Operator and switch
  • It has the following form and always returns a
    value of one of the two exps.
  • Logical exp? exp1exp2
  • 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

5
Loops
  • Different types (for, while, dowhile)
  • 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
Write a Comment
User Comments (0)
About PowerShow.com