CS 0401 Lecture Notes - Lecture 3: Short Circuit
50 views2 pages
Document Summary
Can use relational operators tests for the truth between the values. Must express true or false on both sides. The operators will not change the value, they just create a temporary copy of the value. When mixing boolean and relational operators relational operators have higher priority than boolean operators. Short circuiting the result can be determined before the entire expression has been examined. it with null. How does short circuiting save us? anything is false) finding the length of something that doesn"t exist. If you reverse the line of code, because it will read left to right, it will not short circuit, and it will crash. This means that there is no string, so it will replace. When you have a false && scenario the expression is already false. (false and. This will crash your program tried to do an impossible thing by. // do stuff if (s != null && s. length() > 5) count++;
Get access
Grade+
$40 USD/m
Billed monthly
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers