JAVA.STMT.DO.BLOCK
The body of a do statement must be a block surrounded by {and}.
Vulnerability and risk
If you omit the curly braces in the body of a do statement, a careless programming error may occur.
Mitigation and prevention
Use curly braces in the body of a do statement.
Example 1
Copy
public class C18 {
public void testNGDo(int some_number) {
int i = 0;
do //NG
i++;
while(i < some_number);
int j = 0;
do //NG
;
while (j < some_number);
}
public void testOKDo(int some_number) {
int i = 0;
do {
i++;
} while(i < some_number);
int j = 0;
do {
;
} while (j < some_number);
}
}