01Chapter 1: Build Conditions That Evaluate to true or falseA condition is a test with a yes-or-no answer. In Java, those answers are written as true and false. For example, “Is the score at least 70?” is a condition. If the score is 85, the answer is true. If the score is 60, the answer is false.3 min read
02Chapter 2: Run One Block with if and elseA program does not have to do the same thing every time it runs. Suppose a quiz program needs to show one message when a learner passes and a different message when they do not. In Java, you can write that decision with if and else.3 min read
03Chapter 3: Test Multiple Conditions in the Right OrderSuppose a score of 90 or more should earn “Excellent,” a score from 70 to 89 should earn “Pass,” and a lower score should earn “Keep practicing.” You want to print just one message. An else-if chain lets you list these choices in order and stop at the first one that fits.3 min read
04Chapter 4: Nest Decisions and Use Braces to Clarify Which else Belongs WhereSometimes you need to answer one question before another question matters. Say you want to enter a study room. First, check whether the room is open. If it is, check whether you have a pass. If the room is closed, there is no need to check your pass.3 min read
05Chapter 5: Match a Selector Value to a case or defaultA switch statement chooses what code to run based on one value. Think of a menu with two choices: 1 for Start and 2 for Settings. When the choice is 2, the program should open Settings. If the choice is not on the menu, the program can show a message instead.3 min read
06Chapter 6: Read Colon-Style Cases and Control Fall-Through with breakA switch statement uses one value to pick where to start running code. That value is called the selector. In a colon-style switch, a case label such as case 2: marks a place to start. The colon is the punctuation mark at the end of the label.3 min read
07Chapter 7: Use Arrow-Style Cases That Do Not Fall ThroughAn arrow-style switch statement picks an action based on one value. The value it checks is called the selector. Each case label lists a value that can match the selector. The arrow connects the label to the action on its right. Together, the label and its action form a rule.3 min read
09Chapter 9: Compute a Value with an Exhaustive switch Expression and yieldA switch statement chooses an action to run. A switch expression chooses a value to use. An expression is a piece of code that produces a value, like 20 minus 5. You can save the result of a switch expression in a variable, just as you can save the result of that subtraction.4 min read