| English | 意味 |
|---|---|
| Boolean expression/ˈbuːlɪən ekˈspreʃn/ | ブール式 |
| relational operators/rɪˈleɪʃənl ˈɒpəreɪtəz/ | 関係演算子 |
true or false
- A Boolean expression 布尔表达式 evaluates to exactly one of two values:
trueorfalse. - Conditions in
ifstatements and loops are Boolean expressions. - Store one in a
booleanvariable:boolean passed = score >= 60; - Everything in selection and repetition rests on these
true/falseresults.
Relational operators
- Relational operators 关系运算符 compare two values and give a Boolean:
<less than,<=at most,>greater than,>=at least.==equal to,!=not equal to.5 > 3istrue;4 == 5isfalse.

The three families of operators: arithmetic, relational, and logical
== versus =
==tests equality;=assigns — completely different jobs.x == 5asks "isxequal to5?" and givestrue/false.x = 5stores5inx.- Using
=where you meant==is a classic bug (and often a compile error in a condition).
Predicting the value
- To evaluate a Boolean expression, plug in the values and apply the operator.
- With
x = 7:x < 10→true;x == 7→true;x != 7→false. - Read the operator carefully —
<=includes equality,<does not. - Being able to predict the result is the core skill for tracing code.
== compares; = assigns — never confuse them in a condition. if (x = 5) is wrong (it assigns, not compares); you want if (x == 5). And mind the boundary operators: x <= 10 is true when x is exactly 10, but x < 10 is false — an off-by-one that flips many conditions.
With int age = 18;:
age >= 18→true(18 is at least 18).age > 18→false(18 is not greater than 18).age == 18→true;age != 20→true.
A Boolean expression evaluates to true or false, using relational operators < <= > >= == !=. Remember == tests equality while = assigns, and that <=/>= include the boundary but </> don't. Store a result in a boolean variable to reuse it.
ブールの結果
ブール式は真(1)または偽(0)に評価されます。
2つの値が等しいかどうかを試す演算子はどれですか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
==は等価性をテストし、=は代入を行います。
int age = 18; の場合、age > 18 は真です。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
18は18より大きくないため、age >= 18 が真となります。
int x = 7; の場合、x <= 7 は真です。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
<= は等価性を含むため、7 <= 7 は真です。
5 != 5 の評価結果は何になりますか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
!= は「等しくない」を意味します。5は5と等しいため、結果は偽です。
真または偽を格納する変数の型は ___ です(単語1つ)。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
boolean は true/false を保持します。