Keeping things tidy

You have probably noticed that the Java code in our projects is indented. For example, the first line of code inside the SubHunter class is indented by one tab. And the first line of code is indented inside each method. Here is an annotated image to make this clear and as another quick example:

Keeping things tidy

Notice also that when the indented block has ended, often with a closing curly brace } that } is indented to the same extent as the line of code which began the block.

Tip

Android Studio does much of this automatically, but it does not keep things 100% organized, hence this discussion.

We do this to make the code more readable. It is not part of the Java syntax however and the code will still compile if we don't bother to do this.

As our code gets more complicated, indenting along with comments, help to keep the meaning and structure of our code clear. I mention this now because when we start to learn the syntax for making decisions in Java, indenting becomes especially useful and it is recommended that you indent your code the same way.

Much of this indenting is done for us by Android Studio but not all of it.

Now we know how to present our code more clearly let's learn some more operators and then we can really get to work taking decisions with Java.