Recap - Simple Logic
CoddyのJavaジャーニー「基礎」セクションの一部 — レッスン 24/73。
チャレンジ
初心者以下のコードスニペットが与えられています。b4 が true に評価されるように、変数 b1、b2、b3 にブール値 (true または false) を割り当てるのがあなたのタスクです。
変数 b4 は以下のロジックを使用して計算されます:
- b1、b2、および b3 の NOT に対して AND 演算 (&&) を行います
- b4 が true になるためには、AND 演算のすべての部分が true でなければなりません
自分で試してみよう
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);
}
}基礎のすべてのレッスン
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