Start of Tutorial > Start of Trail > Start of Lesson | Search |
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, theSystem.out.println
statement within the curly brackets is executed only if the method callCharacter.isUpperCase(aChar)
returns true:The Java programming language provides several control flow statements, including:if (Character.isUpperCase(aChar)) { System.out.println("The character " + aChar + " is upper case."); }
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
- The while and do-while Statements
- The for Statement
- The if-else Statement
- The switch Statement
- Exception Handling Statements
- Branching Statements
Note: Althoughgoto
is a reserved word, currently the Java programming language does not support thegoto
statement.
Start of Tutorial > Start of Trail > Start of Lesson | Search |