From the course: Oracle Java Foundations
Unlock this course with a free trial
Join today to access over 24,000 courses taught by industry experts.
Flow control - Java Tutorial
From the course: Oracle Java Foundations
Flow control
- [Instructor] Controlling program flow. One of the things we need to do in computer programs is to control the flow of logic, that is, how the program executes. One way to do that is with an if/else statement which can make a decision. Using the if statement, we can evaluate a condition, and if the condition is true, we would take whatever programmed action that we have. Optionally, we can also have an else condition. So, if the condition being tested is false, we would do the else block. This is optional and not required, but typically, you'll see both, an if and an else together. We use our conditional operators in order to help write the conditional expressions. For example, we can use the logical "AND", "OR" and "NOT". AND says if both conditions are true, then the whole expression is true. If any part is false, then the entire expression is false. OR says if any part of the expression is true, the entire expression is true. For example, here, int I equals two, J equals eight. If…