CS 18000 Lecture Notes - Lecture 4: Exclusive Or, Null Pointer
Document Summary
Selection: by default, a list of statements , statement 1, statement 2, statement n, is executed in order, one after another, unless there is an error ( exception ), all statements are executed, we say, control flows sequentially. Control structures: language features (syntax) that affect the flow of control in a program, default control flow is sequential, control flow jumps to methods, then returns, various keywords introduce changes to the default flow, if, switch, while, for. Comparing strings: == between objects only compares the references (addresses) of the objects, two different string objects with the exact same characters will compare == false (since their objects are stored in different locations) if (s1. equals(s2)) Basic forms of the if statement if (boolean-expression) statement-if-true; if (boolean-expression) statement-if-true; else statement-if-false; Blocks and braces: use braces ({}) to group a sequence of statements into a single unit, already seen with method bodies and other examples, also can be use for control structures.