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 that the first line of code is indented inside each method. Here is an annotated image to make this clear:
Also, notice that when the indented block ends, often with a closing curly brace, }
, that }
is indented to the same extent as the line of code that 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 becomes more complicated, indenting, along with comments, helps keep the meaning and structure of our code clear. I am mentioning this now because when we start to learn...