Stellar

Stellar

Did you know?

The Hubble Space Telescope has taken over 1.4 million observations of space!

Having trouble connecting?

Join Discord | Email Us

3.1 Boolean Expressions

Section 1 of 6

Interactive Content
Note: All content in this lesson is interactive. Hover over the glowing blue terms to learn more about a Vocabulary term. Hover over the icons to learn more about a Key Formula or Graph. Hover over any line, point, or curve on any graph or diagram to learn more about it.

Boolean expressions are like simple “yes or no” questions that a computer can answer. When you compare two values (e.g., Is 5 greater than 3?), the result is always either true or false. This true-or-false logic is how your computer decides which instructions to execute next: if the condition is true, it follows one path; if it’s false, it follows another. There are quite a few symbols that can be used to form boolean expressions. The first one is the == (equal-to) operator, which tests whether the expression on the left is equal to the expression on the right.

java

1
2
3
4
5
6
7
8
9
10
11
12
int x = 5;
int y = 5;
boolean isEqual = (x == y);
System.out.println(isEqual);

int a = 5;
int b = 10;
System.out.println(x == y);

int a = 7;
int b = 7;
System.out.println(a == b);

Output

true
false
true
Nova

Nova

Nova

Ask Nova a question!