The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search

Trail: Learning the Java Language
Lesson: The Nuts and Bolts of the Java Language

Control Flow Statements

When you write a program, you type Java language statements into a file. Without control flow statements, the interpreter executes these statements in the order they appear in the file from top to bottom, left to right. You can use control flow statements in your programs to conditionally execute statements, to loop over a block of statements, and so on. For example, in the following code snippet, the System.out.println statement within the curly brackets is executed only if the method call Character.isUpperCase(aChar) returns true:
if (Character.isUpperCase(aChar)) {
    System.out.println("The character " + aChar + " is upper case.");
}
The Java programming language provides several control flow statements, including:

Statement Type Keyword
looping while, do-while , for
decision making if-else, switch-case
exception handling try-catch-finally, throw
branching break, continue, label:, return


Note: Although goto is a reserved word, currently the Java programming language does not support the goto statement.

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search