Recap - Simple Logic
Parte da seção Fundamentos do Journey de Java da Coddy — lição 24 de 73.
Desafio
InicianteDado o seguinte trecho de código, sua tarefa é atribuir valores booleanos (true ou false) às variáveis b1, b2 e b3 para que b4 resulte em true.
A variável b4 é calculada usando a seguinte lógica:
- Ela realiza uma operação AND (&&) entre b1, b2 e o NOT de b3
- Para b4 ser true, todas as partes da operação AND devem ser true
Experimente você mesmo
public class Main {
public static void main(String[] args) {
boolean b1 = ?;
boolean b2 = ?;
boolean b3 = ?;
boolean b4 = b1 && b2 && (!b3);
System.out.println("b4 = " + b4);
}
}Todas as lições de Fundamentos
4Operators Part 1
Arithmetic OperatorsModulo OperatorIncrement/DecrementPost Increment/DecrementArithmetic ShortcutsComparison OperatorsString Comparison5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Logical Operators Part 43Variables Part 2
ConstantsNaming ConventionsRecap - Initialize VariablesType Casting Part 1Type Casting Part 26Decision Making
If StatementIf - ElseSwitch StatementTernary OperatorRecap - If ElseNested If - Else