...

/

Comparison and Logical Operators

Comparison and Logical Operators

Learn how to compare values.

Comparison and logical operators

We know how to use built-in methods as well as define our own methods. We also know how to take input from the user and assign it to a variable for storage (and reuse) or pass it as further input to a method. We also know how to output something on the screen for the user. But we can only write sequential programs so far, where the computer fetches and executes one line of our code after another, from the first executable line of the main method to the last, in a strictly sequential order.

Press + to interact
canvasAnimation-image
1 / 3

This equips us with the necessary skills to solve many interesting problems, but there are still some problems that sequential programs can’t solve. Sometimes, a solution might require nonsequential execution as well:

Press + to interact
canvasAnimation-image
1 / 3

This chapter is about learning how to write programs that can, while they’re executing, be selective about executing lines of code. Secondly, we’ll learn to write programs that can execute some lines of our code ...