ITEC 120: Week 8
- Program 2 due Monday (10/11)
- CLASS QUIZ Tuesday (10/12)!
- LAB QUIZ Wednesday (10/13)!
- Review of chapter 4: class Box, UML, encapsulation
- Chapter 5: If statements
- Flow of control: Statements are executed in sequence, unless directed otherwise
- Flow of control: Otherwise: method calls, conditionals (if, if-else, switch), loops
- An if statement hierarchically nests another statement inside it
- The nested statement is only executed if the if condition is true
- The nested statement can be another if statement
- Let your indentation reflect the program's hierarchy
- The condition is an expression that is true or false
- Equality operators (== and !=) compare two values for equality
(can be used for numeric and boolean values and objects)
- Careful: don't confuse equality operator (ie ==) and assignment operator (ie =)
- For objects == compares the references, not the object fields
- For objects, .equals is usually better than ==
- For Strings, always use .equals since == can be misleading
- Relational operators determine the relative sizes of two values (can only
be used for numeric values)
- Be careful of precedence of operators (eg 2+3 < 4+5)
- Examples from Chapter 5
- Chapter 5 Powerpoint Slides
- Semester
Calendar