lecture6 - PIC 20A Lecture 6 Specifying Control Flow in...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
PIC 20A Lecture 6: Specifying Control Flow in Java Enumerated Types
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is Control Flow? • the order in which statements are to be executed in a computer program
Background image of page 2
How can we affect control flow? via 3 types of control structures: 1. sequence 2. selection if (single selection structure), if/else (double selection), conditional ternary operator ( ? : ) if/else/else, switch (multiple selection) 3. repetition/iteration while, do-while, and for loops
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sequence Structures What is a block ? • a sequence of statements grouped into a single compound statement by curly braces { } eg { int a = 3; System.out.println(“” + a); }
Background image of page 4
Single Selection Structures if statement Syntax: if(condition) statement; or if(condition) { // block of statements }
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Double Selection Structures if/else statement Syntax: if(condition) statementIfTrue; else statementIfFalse;
Background image of page 6
Double Selection Structures if/else statement Syntax: if(condition) { // block if c true } else { // block if c false }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/12/2010 for the course PIC PIC 20A taught by Professor Keithouellette during the Spring '09 term at UCLA.

Page1 / 18

lecture6 - PIC 20A Lecture 6 Specifying Control Flow in...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online