|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
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.printlnstatement 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,fordecision making if-else,switch-caseexception handling try-catch-finally,throwbranching break,continue,label:,return
- The while and do-while Statements
- The for Statement
- The if/else Statements
- The switch Statement
- Exception Handling Statements
- Branching Statements
- Summary of Control Flow Statements
- Questions and Exercises: Control Flow
Note: Althoughgotois a reserved word, currently the Java programming language does not support thegotostatement.
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |