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:
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.
Note
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...