To make your code easier to read, many textbooks and companies use a style guide that defines some of the formating rules that you should follow in your source code. However, this is a point of contention, and many folks disagree over what is the best format. These formatting rules do not affect the actual code itself, only how easy it is to read.

For this book, most of the examples will be presented in a variant of the K&R Style used by most Java developers, which places the opening brace on the same line as the declaration, but the closing brace is placed on a line by itself and indented at the same level as the declaration. The code inside will be indented by four spaces.

Google provides a comprehensive style guide that is recommended reading if you’d like to learn more about how to format your source code.


Try It!

Codio also includes a special assessment that will validate the coding style of your code based on the Google style guide. Use the assessment below to make sure your solution to Exercise 1 meets the expected coding style standard.


We will also be enforcing this style on many projects and assignments in this class, so it is very important to become familiar with proper coding style!