L3a Java Selection

L3a Java Selection - If/then/else JAVA SELECTION CONCEPTS Background You should remember most of this stuff from your Programming Concepts class

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

View Full Document Right Arrow Icon
JAVA SELECTION CONCEPTS If/then/else
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background You should remember most of this stuff from your Programming Concepts class This is a brief review If/else in Java looks essentially identical to the same constructs in C. Most of the complexity of programs comes from the if statements, not the calculations (except for some scientific programs)
Background image of page 2
Independent if’s These may all be true, or none may be true Example: if ( a ) { System.out.println ( "a" ) ; } if ( b ) { System.out.println ( "b" ) ; }if ( c ) { System.out.println ( "c" ) ; }
Background image of page 3

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

View Full DocumentRight Arrow Icon
Mutually exclusive if’s One or another but not both can be true Example: if ( a ) { System.out.println ( "a" ) ; } else if ( b ) { System.out.println ( "b" ) ; }else if ( c ) { System.out.println ( "c" ) ; }
Background image of page 4
Mutually exclusive if’s (cont) Old school example if ( a ) { System.out.println ( "a" ) ; return ; } if ( b ) { System.out.println ( "b" ) ; return ; } if ( c ) { System.out.println ( "c" ) ; return ; }
Background image of page 5

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

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

This note was uploaded on 03/01/2012 for the course COP 2800 taught by Professor Geraldreed during the Spring '08 term at Valencia.

Page1 / 11

L3a Java Selection - If/then/else JAVA SELECTION CONCEPTS Background You should remember most of this stuff from your Programming Concepts class

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

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