GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

Decision Statements

John Hair Englisch

Inhalt der Mindmap

Decision Statements

  1. If statements: checks if the condition given is true. If true, then it will execute the code embeded in it.

    • Brackets vs. Dangling: In order to have multiple operations occur, you must have brackets. If you only need one line, then you can just put it under the condition, also known as dangling
  2. Comparing values

    • For number types, you can use the "==" operator
    • For objects and strings, you must use the "compareTo" method
  3. Boolean expressions: determines if true or false

    • ||(or) returns true if at least one condition is true
    • &&(and): returns true if both conditions are true
    • !(not): returns true if condition is false.
    • Demorgans law: !(a || b) is the same as (!a && !b); and !(a && b) is the same as (!a || !b)
    • Short circuit: When java finds one side of an && to be false; or finds one side of || to be true; it will return false/true without checking the other side.
  4. Common mistakes

    • x > 0 && x < 100; not 0 < x < 100
    • color == "green" || color == "blue"; not color == "green" || "blue"
    • Use compareTo with strings and objects instead of the "==" operator
    • null is not the same as an empty string
    • do not put a semicolon at the end of an if statement

Informationen

Beschreibung
Mindmap am Decision Statements, erstellt von John Hair am 26/04/2018.
Erstellt von
John Hair
Aufrufe
1
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck