4.3. if Single-Selection Statement

4.3. if Single-Selection Statement

Programs use selection statements to choose among alternative courses of action. For example, suppose that the passing grade on an exam is 60. The statement

if ( studentGrade >= 60 )
   System.out.println( "Passed" );

determines whether the condition "studentGrade >= 60" is true or false. If it is true, "Passed" is printed, and the next statement in order is "performed." If the condition is false, the println statement is ignored, and the next statement in order is performed.

-