Booleans

Logical data types that only have true or false values. In java it is usually used to determine which sections of code to execute.

If Statements and other Conditionals

Will check boolean value and execute based on whether the conditions is met or not. The If statement is used to check the first condition and if that requirement is met, then it will execute the command. The else statement follows after and executes another command in case the original requirement for the if statement was not met. The else if comes in between and shows another condition to meet and will run if it is met.

if (score >= 90) {
    grade = 'A'; 
 } else if (score >= 80) {
    grade = 'B';
 } else if (score >= 70) {
    grade = 'C';
 } else if (score >= 60) {
    grade = 'D';
 } else {
    grade = 'F'
 }

De Morgan's Law

Kind of like probability in stats, it is used to help you add multiple conditions to your boolean value. You can use || to represent "or" and && to represent "and".

boolean cat = true;
boolean spotted = false;

if (!(cat && spotted)){
    System.out.println("You have a spotted cat");
} else{
    System.out.println("Your cat is not spotted");
}
You have a spotted cat