Basic HTML version of Foils prepared Sept 6 1998

Foil 11 Java Language -- Control Flow I

From Java Tutorial 98-2: Java Language and Object Oriented Techniques CPS606 Fall Semester 1999 -- Sept 7 1999. by Geoffrey C. Fox, Nancy McCracken

application examples for Foil 11
if (some boolean expression) { .. }
  • else { ... } // optional else
Nested: if (some boolean expression) { .. }
  • else if(another boolean) { .. }
  • else { ... }
while (any boolean) { /* Do Stuff */ }
do { /* What to do */ } while (another boolean);
for (expression1; booleanexpression ; expression2) { ...}
  • naturally starts with expression1, applies expression2 at end of each loop, and continues as long as booleanexpression true
    • for ( int i=0; i<length(a); i++)
    • a[i] = i * i;
    • /* loop variable i is optionally declared to be local to loop as shown here. */



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Mon Sep 6 1999