Skip to main content
Logo image

Chapter 4 Booleans and conditionals

Now that we know how to structure our code using methods, we need to learn some more basics about how to write the code that goes in our methods. In this unit and the next we will look at Java’s control constructs, the parts of the lanuage that allow us to control what happens when. With just a few basic control constructs we will be able to write code to implement any algorithm that it is possible to run on a computer.
In this chapter we will introduce the notion of algorithms and then talk about if statements which allow us to write programs that do things only if certain conditions are true.