Help shape GoConqr. What should we add next?

Mind map

Pages 57-72 and 199-201

Gary Jones English

Mind map on Java statements and control flow structures: If, While, For, Break and Switch Statements

Mind map: Java statements and control flow structures

Map content

Pages 57-72 and 199-201

  1. 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
    • 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
  2. 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
  3. 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)
  4. 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
  5. The Break Statement

    • Used to break from a do, while, for or switch statement. Results in a compile error anywhere else
  6. 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.
  7. 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
  8. 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}

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

Feedback

What is it about?

What should we add next?