Basic HTML version of Foils prepared October 30 1999

Foil 11 "If" Statements

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. by Nancy McCracken


1 This statement is also called a "conditional" statement. It tests a "condition" and if it's true, it executes the first set of statements, and if it's false, instead it executes a second set of statements.
2 if ( num == 0 )
3 { y = 0; g.setColor ( Color.red ); }
4 else
5 { y = 1; g.setColor ( Color.black ); }
6 if and else are keywords
7 The condition is in ( )s.
8 If the condition is true, execute these statements,
9 otherwise these.

in Table To:


© 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 Sat Oct 30 1999