Mind map
Pages 57-72 and 199-201

Mind map: Java statements and control flow structures
Map content
Pages 57-72 and 199-201
Overview of Java Statements
- Satements = instruction to do something
- Can be grouped in a block which is a statement, local class declarations, and local variable declaration statements
- Statements and blocks can be labeled so that it can be referenced by the break and continue statements
- sectionA: x = y+1;
- Can be used with break statements to break a do, while, switch, continue statements, or for code . " break start;"
- Identical to former bubble
- Statements and blocks can be labeled so that it can be referenced by the break and continue statements
- Can be grouped in a block which is a statement, local class declarations, and local variable declaration statements
- Expression = combination of operators and operands
- Some can turn into statement by ending in a semicolon. x++;
- Writing multiple statements on one line not recommended. It obscurs readability
- Satements = instruction to do something
The If Statement
- Either if (boleanExpression) alone; or if/ else
- If expression is true. Code is run. If false, code is not run
- Shorthand expressions: if(fileExists). Or if(!fileExists). No need for == or !=
- Dangling else statement can arise if braces aren't used
- If expression is true. Code is run. If false, code is not run
- Either if (boleanExpression) alone; or if/ else
The While Statement
- used when you want to perform an action multiple times in a row
- while (booleanExpression){statement(s)}
- The do-while Statement
- Similar to while loop but the code is guaranteed at least 1 execution
- do{statements}while(booleanExpression)
- Similar to while loop but the code is guaranteed at least 1 execution
- used when you want to perform an action multiple times in a row
The For Statement
- for (init; booleanExpression; update){Statements}
- Only stops if booleanExpression evaluates to false; a break or continue statement is executed, a runtime error occurs
- for (init; booleanExpression; update){Statements}
The Break Statement
- Used to break from a do, while, for or switch statement. Results in a compile error anywhere else
The Continue Statement
- Similar to break, but it stops only the execution of the current iteration of the code and causes control to start with next iteration.
The Switch Statement
- Alternative to else if. must return an int, string, or enumerated value
- switch(expression){case value_1: statements; break;}
- not adding break statement will cause next case to run as well
- switch(expression){case value_1: statements; break;}
- Alternative to else if. must return an int, string, or enumerated value
Enum
- Used to create a set of valid values for a field or a method
- Can be stand alone (referenced throughout code) or part of a class (used once)
- guarantees that that the assigned value can only be a valid value
- Enumerated values are objects
- public enum CustomerType { INDIVIDUAL, ORGANIZATION}
- guarantees that that the assigned value can only be a valid value
- Can be stand alone (referenced throughout code) or part of a class (used once)
- Used to create a set of valid values for a field or a method
Information
- Description
- Mind Map on Pages 57-72 and 199-201, created by Gary Jones on 26/06/2019.
- Created by
- Gary Jones
- Views
- 0
- Rating