Page 796 - Introduction to Programming with Java: A Problem Solving Approach
P. 796
762 Appendix 5 Java Coding-Style Conventions Placement of Braces
1. Place opening and closing braces on lines by themselves such that the braces are aligned with the line above the opening brace. For do loops, put the while condition on the same line as the closing brace.
2. Examples:
public class Counter
{
}
}
<field-and-method-declarations>
if (...)
{
<statements> else if (...)
}
{
<statements> else
}
{
<statements>
Apago PDF Enhancer
for/while (...)
{
}
do
{
<statements>
<statements>
} while (...);
switch (...)
{
}
case ... :
<statements>
break;
case ... :
<statements> break;
...
default:
<statements>