Jtest logo




Contents  Previous  Next  Index

PB.IEB


Avoid "if" statements with empty bodies

Description

This rule flags any "if" statement with an empty body.

"if" statements that are immediately followed by closing statements (for example, a semicolon) are usually typos.

Example

 package PB;
 
 public class IEB {
     void method (int i) {
 	 if (i < 0) ;
 	 	 System.out.println("negative i");
     }
 }

The `println()' statement will always be executed regardless of the value of `i'.

Repair

Remove the unnecessary semicolon.


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft